StrScan

Searches string for occurrence of delimiters.

Syntax:

StrScan (string, delimiters, start, direction)

Parameters:

(s) string the string that is to be searched.

(s) delimiters a string of delimiters to search for within string.

(i) start the position in the main string to begin search.  The first character of a string is position 1.

(i) direction the search direction. @FWDSCAN searches forward, while @BACKSCAN searches backwards.

Returns:

(i) position of delimiter in string, or 0 if not found.

 

This function searches for delimiters within a target "string". Starting at the "start" position, it goes forward or backward depending on the value of the "direction" parameter. It stops when it finds any one of the characters in the "delimiters" string within the target "string".

A start position of 0 has special meaning depending on which direction you are scanning. For forward searches, zero indicates the search should start at the beginning of the string. For reverse searches, zero causes it to start at the end of the string.

Example:


; Parse a string with multiple delimiters into standard param format
thestr = "123,456.789:abc"
length=StrLen(thestr)
start = 1
count=0
While @TRUE
   finish = StrScan(thestr, ",.:", start, @FWDSCAN)
   If finish == 0
      Break
   Else
      count = count+1
      param%count% = StrSub(thestr, start, finish - start)
      start=finish+1
      Message("Parameter number %count% is", param%count%)
      If finish == length Then Break
   EndIf
EndWhile
If start <= length
   finish = length+1
   count = count+1
   param%count% = StrSub(thestr, start, finish - start)
   Message("Parameter number %count% is", param%count%)
EndIf
param0 = count
Message("Parameter count is",param0)
See Also:

StrInsert, StrLen, StrSub, StrIndexWild, StrOverlay