scan() function

The scan() function searches through a specified str.exp for the first occurrence of up to three user-definable characters specified by search.delimiters, in addition to the system delimiters value, subvalue, and attribute.

Syntax

 scan(str.exp, search.delimiters)

Parameter(s)

str.exp Specifies the string to search.
search.delimiters Specifies up to three user-definable characters to be searched for in addition to the system delimiters value, subvalue, and attribute. The user-defined characters must be separated by a system delimiter.

Description

The following information applies to the scan() function:

  • If the delimiter is found, the scan() function returns the numeric position where the occurrence was found.
  • If the specified search delimiters or any system delimiters are not found, the scan() function returns 0.

Example(s)

Example 1

The following example returns the value 5 to the variable d.position. This is because the first occurrence of either \’\ or \"\ is found in the fifth position of the string.
 
 String = \The "first" or ’second’ name.\
 d.position = scan(string,\’\:@am:\"\)

Example 2

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.
 
 loop
 input ans,1
 until scan(’abc’,ans) do repeat