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

FIND Syntax FIND expr IN dyn.array[,occur] SETTING f [,v[,s]] {THEN statements | ELSE statements} Description The UniBasic FIND command determines the position of the given expression in a dynamic array. FIND returns the attribute, value, and subvalue position of the found string. The expression must match the entire array element to make a match. Parameters The following table describes each parameter of the syntax. Parameter Description 1-260 UniBasic Commands Reference expr Specifies the expression to find. expr must be either a numeric value or a string value. dyn.array Specifies the dynamic array in which to find expr. ,occur Specifies the occurrence of expr to find. The default is 1 (the first occurrence). FIND Parameters

Parameter Description f,v,s Specifies variables in which to place the position of expr: f – Attribute v – Value s – Subvalue If the attribute found has neither multivalues nor subvalues, then v and s, if specified, are set to 0. If only multivalues are present, s is set to 0. If only subvalues exist, v is also set to 0. THEN statements ELSE statements For more information about writing THEN...ELSE parameters, see Developing UniBasic Applications. The UniBasic FIND and LOCATE commands are compared in this manual. Examples Specifies statements to execute if the expr is found in the array. END is required when statements extend over more than one line. Either a THEN statement or an ELSE statement is required. Specifies statements to execute if the expr is not found in the array. END is required when statements are multiline. Either a THEN statement or an ELSE statement is required. FIND Parameters (continued) In the following example, the program segment searches for an occurrence of 31 in the string DA. This results in F=3, V=1, and S=0 because 31 is found in the third attribute as the first multivalue, and this attribute has no subvalues. 001: DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43 002: FIND 31 IN DA SETTING F,V,S THEN 003: PRINT "F=":F:" V=":V:" S=":S 004: END ELSE 005: PRINT "NOT FOUND" 006: END In the next example, the program segment searches for the second occurrence of 41 in the string DA. This results in F=3, V=4, and S=0 because the second occurrence of 41 is found in the third attribute as the fourth multivalue, and this attribute has no subvalues. DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43 FIND 41 IN DA,2 SETTING F,V,S ELSE PRINT "NOT FOUND" FIND 1-261

Parameter Description<br />

f,v,s Specifies variables in which to place the position of expr:<br />

f – Attribute<br />

v – Value<br />

s – Subvalue<br />

If the attribute found has neither multivalues nor subvalues, then v and s, if<br />

specified, are set to 0. If only multivalues are present, s is set to 0. If only<br />

subvalues exist, v is also set to 0.<br />

THEN<br />

statements<br />

ELSE<br />

statements<br />

For more information about writing THEN...ELSE parameters, see Developing<br />

<strong>UniBasic</strong> Applications. The <strong>UniBasic</strong> FIND and LOCATE commands are compared<br />

in this manual.<br />

Examples<br />

Specifies statements to execute if the expr is found in the array. END is<br />

required when statements extend over more than one line. Either a THEN<br />

statement or an ELSE statement is required.<br />

Specifies statements to execute if the expr is not found in the array. END is<br />

required when statements are multiline. Either a THEN statement or an<br />

ELSE statement is required.<br />

FIND Parameters (continued)<br />

In the following example, the program segment searches for an occurrence of 31 in<br />

the string DA. This results in F=3, V=1, and S=0 because 31 is found in the third<br />

attribute as the first multivalue, and this attribute has no subvalues.<br />

001: DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43<br />

002: FIND 31 IN DA SETTING F,V,S THEN<br />

003: PRINT "F=":F:" V=":V:" S=":S<br />

004: END ELSE<br />

005: PRINT "NOT FOUND"<br />

006: END<br />

In the next example, the program segment searches for the second occurrence of 41<br />

in the string DA. This results in F=3, V=4, and S=0 because the second occurrence<br />

of 41 is found in the third attribute as the fourth multivalue, and this attribute has no<br />

subvalues.<br />

DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43<br />

FIND 41 IN DA,2 SETTING F,V,S ELSE PRINT "NOT FOUND"<br />

FIND 1-261

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

Saved successfully!

Ooh no, something went wrong!