UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

Examples The following program segment is taken from the sample program in Appendix A, “Sample Program,” in Developing UniBasic Applications. The variable ENTRY is used to extract the user-requested values from the ORDERS record. 1-278 UniBasic Commands Reference DISPLAY_DATA: * Display the current information in the desired record. This is * determined by the number the user entered (ORDER_NUMBER). ... NUM_ENTRIES = DCOUNT(ORDER.REC,@VM) FOR ENTRY = 1 TO NUM_ENTRIES PRODUCT_NUMBER = ORDER.REC COLOR = ORDER.REC QUANTITY = ORDER.REC PRICE = OCONV(ORDER.REC,"MD2$,") In the following example, the program segment assigns the string Joan to the variable MID. Joan is the second attribute in the dynamic array ARR. The value and subvalue expressions are 0, resulting in the extraction of an attribute. ARR = "#543":@AM:"Joan":@AM:"D’Arc" MID = EXTRACT(ARR,2,0,0) In the next example, the program segment assigns the string Dagny, the second value of the third attribute, to the variable MID: ARRAY = "#143":@AM:"Gustav":@AM:"Mahler":@VM:"Dagny":@VM:"Jens" MID = EXTRACT(ARRAY,3,2) Related Commands UniBasic DEL, INSERT, REMOVE, REPLACE, SUBSTRINGS

FIELD Syntax FIELD(string.expr,delim.expr,field.expr [,rep.expr]) Description The UniBasic FIELD function treats a string as an array, with fields delimited by any specified ASCII character (for example, spaces, commas, or periods), and returns a substring or group of substrings. FIELD supports multibyte languages. Parameters The following table describes each parameter of the syntax. Parameter Description string.expr Specifies the string expression to search. delim.expr Specifies the field delimiter. field.expr Specifies the field at which to begin the search. ,rep.expr Specifies the number of fields to return. If you do not specify rep.expr, or it is less than 1, UniData returns a default of 1 substring. FIELD Parameters Examples In the following example, the program segment assigns the third value (“Guy”) in the array ARR to the array NARRAY: ARR = "#999":@VM:"Charlemagne":@VM:"Guy":@VM:"Pierre" NARRAY = FIELD(ARR,@VM,2,1) FIELD 1-247

FIELD<br />

Syntax<br />

FIELD(string.expr,delim.expr,field.expr [,rep.expr])<br />

Description<br />

The <strong>UniBasic</strong> FIELD function treats a string as an array, with fields delimited by any<br />

specified ASCII character (for example, spaces, commas, or periods), and returns a<br />

substring or group of substrings. FIELD supports multibyte languages.<br />

Parameters<br />

The following table describes each parameter of the syntax.<br />

Parameter Description<br />

string.expr Specifies the string expression to search.<br />

delim.expr Specifies the field delimiter.<br />

field.expr Specifies the field at which to begin the search.<br />

,rep.expr Specifies the number of fields to return. If you do not specify rep.expr, or it<br />

is less than 1, UniData returns a default of 1 substring.<br />

FIELD Parameters<br />

Examples<br />

In the following example, the program segment assigns the third value (“Guy”) in the<br />

array ARR to the array NARRAY:<br />

ARR = "#999":@VM:"Charlemagne":@VM:"Guy":@VM:"Pierre"<br />

NARRAY = FIELD(ARR,@VM,2,1)<br />

FIELD 1-247

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!