SCAN

SCAN


sc.expression Index Level Boolean Evaluation
Syntax SCAN( string.expression, search.delimeter(s) )
Category BASIC
Type Function
Description searches through a given "string.expression" for the first occurrence of up to three user-definable character(s) specified by "search.delimeter(s)" in addition to the system delimeters: subvalue, value, and attribute. If the delimeter is found, "scan" returns the numeric position at which the occurence was found. The user-defined characters must be separated by a system delimeter (' " \).

If the specified search delimeters or any system delimeters are not found, "0" (zero) is returned.
Options
See Also statements & functions string.expression functions $OPTIONS
Example d.position = scan(\The "first" or 'second' name.\,\'\:AM:\"\)

This returns the value, "5", to the variable "d.position", since the first occurrence of either \'\ or \"\ is found in the fifth position of the string.

on scan("abcdefg","c":VM:"e":VM:"g") goto 10,20,30,40,50,60,70

This example exploits the fact that "scan" returns a number indicating the position of the search character. For instance, if "c" is found then it will goto statement label 30.

loop
input ans,1
until scan('abc',ans) do repeat

If "ans" is either an a, b, or c, the loop is terminated.  Notice that a null value for "ans" results in a "0" from the "scan" function.
Warnings If no match is found the result will be zero.

To use the scan function, it is necessary to use a non-default compiler options setting.  Inserting the line "$options ext" at the beginning of the source item accomplishes this.
Compatibility D3 7.0 R91
sc.expression Index Level Boolean Evaluation