Welcome to jBASE's new documentation site! Many answers to your questions can be found by searching the Knowledgebase or viewing the jBASE Documentation. We also have a Google Group for peer discussion about jBASE. If you are unable to find the information you are looking for, jBASE Support will be glad to assist in resolving your technical problems. Enjoy and please provide comments and feedback .

How can we help you?

FIND

Description

The FIND statement allows the location of a specified string within a dynamic array. It takes the general form:

FIND expression1 IN Var1 {, expression2} SETTING Var2 {, Var3 {, Var4}} THEN | ELSE statement(s)

Where:

  • expression1 evaluates to the string with which to compare every element of the dynamic array.
  • Var1 is the dynamic array that will be searched.

The FIND command will normally find the first occurrence of expression1unless expression2 is specified. If specified then expression2 will cause a specific occurrence of expression1 to be located. The three variables Var2, Var3, Var4 are used to record the Field, Value and Sub-Value positions in which expression1 was found.

If expression1 is found in any element of Var1 then Vars 2, 3 and are set to the position in which it was found and any THEN clause of the statement is executed. If expression1 is not found within any element of the dynamic array then Vars 2, 3 and are undefined and the ELSE clause of the statement is executed.

Note:

The statement may omit either the THEN clause or the ELSE clause but may not omit both. It is valid for the statement to contain both clauses if required.

An example of use is as: 

0001     V.ARRAY = 'ABC' :@FM: 'DEF' :@VM: 'XYZ' : @SM: 'XYZ'
0002
0003     FIND 'XYZ' IN V.ARRAY SETTING V.FLD, V.VAL THEN
0004         CRT "XYZ is in field: " : V.FLD, "value: ": V.VAL
0005     END
0006
0007     ELSE
0008         CRT "NOT FOUND"
0009     END

to display: 

XYZ is in field 2     value 2


See also: LOCATE, FINDSTR

Go back to jBASE BASIC.

Was this article helpful?