DataBasic Reference > Statements and Intrinsic Functions > F > FIND Statement

Comment on this topic

Documentation Comments

Use this form to comment on this topic. You can also provide any general observations about the Online Documentation, or request that additional information be added in a future release.

RealityV15.1Online Documentation (MoTW) Revision 7

FIND Statement (DataBasic) (m618703+find_s.htm)

To

Reality

Version

Topic

Submitted by

Company

Location

Email address

Comment

 

 

FIND Statement

Locates the position (attribute, value or subvalue) of a string or value in a dynamic array.

Syntax

FIND value IN dynArray{,occurrence} SETTING attrVar{,valVar{,subvalVar}} [THEN statement(s) | ELSE statement(s)]

Syntax Elements

value An expression that evaluates to the string or value being searched for.

dynArray The name of the dynamic array in which to search.

occurrence The number of the occurrence of the element being searched for in dynArray.

If occurrence is not specified, it defaults to 1.

attrVar A variable that is set to the attribute position where the element is found.

valVar A variable that is set to the value position where the element is found.

subvalVar A variable that is set to the subvalue position where the element is found.

statement(s) Either a THEN or ELSE clause (or both). A statement must be included. The THEN clause is executed if the FIND is successful; otherwise the ELSE clause is executed.

Operation

FIND returns the attribute and, if specified, the value and subvalue in which the element is found.

Case Insensitivity

If data case insensitive mode is selected (see Case Sensitivity), case is ignored when searching dynArray for value .

Examples

DYNARR = "A":@AM:"B":@AM:"C":@AM:"D":@AM:"E":@AM:"F":@AM:"G":@AM:"A":@AM:"B":@AM:"C"
FIND "A" IN DYNARR,2 SETTING X ELSE PRINT "NOT FOUND"; STOP

Finds the second occurrence of the element A in dynamic array DYNARR. Sets X to a number indicating the position of that attribute. In this example, X = 8 (the second occurrence of A in DYNARR is its eighth atribute).

ITEM = "24":@AM:"34":@VM:"28":@VM:"31":@AM:"29":@VM:"22":@VM:"21"
X=29
FIND X IN ITEM,1 SETTING A,B ELSE PRINT "NOT FOUND"; STOP
PRINT A,B

Finds the multivalue equal to 29 in attribute A, value B and prints A and B. In this example, A=3 and B=1.

ARR = "44":@AM:"88":@AM:"6":@VM:"2":@VM:"7":@SVM:"3":@SVM:"2":@AM:"8":@AM:"99"
FIND 3 IN ARR,1 SETTING A,B,C ELSE PRINT "CAN'T FIND"; STOP
PRINT A,B,C

Finds numeric literal 3 in attribute 3, value 3, subvalue 2 of dynamic array ARR and prints the contents of A, B and C (3, 3 and 2).

See Also

FINDSTR statement, LOCATE statement.

RealityV15.1 (MoTW) Revision 7Comment on this topic