FINDNEXT, FINDPREV (DSEB only)

Read syntax diagramSkip visual syntax diagram
Syntax

>>-+-FINDNEXT-+--(needle-+-----------------+-+-------+-)-------><
   '-FINDPREV-'          '-,start-+------+-' '-,CASE-'     
                                  '-,end-'                 

(Can be used in FASTREXX procedures.)

Searches for needle in the input data set, from the current input record forwards (FINDNEXT) or backwards (FINDPREV). You can limit the search to a range of columns, or to an exact matching case.

If a FINDNEXT() or FINDPREV() has located a needle on a given record, then repeated searching resumes from the previously located needle plus 1 for FINDNEXT and minus 1 for FINDPREV. If the record location has been changed by an UP(), Down(), TOP(), or BOT() command, or there has been no previous located needle, then FINDPREV searches from the end of the current record backward, and FINDNEXT searches from the start of the current record forward.

Returns
If the search is successful, the record in which needle was found becomes the current input record, and the FINDNEXT function returns the starting column of needle in the record. If the search is unsuccessful, the current input record remains the same, and FINDNEXT returns 0.
needle
String(s) or numeric(s) to search for. The needle can be a character variable in the form &varname where varname matches an existing variable name. If an "&" is coded and a variable name is not found, then the needle is treated as the string value to be searched for.
start
The position, in bytes, of the start of the range in each input record to be searched.
end
The position, in bytes, of the end of the range in each input record to be searched.
CASE
Specifies that the comparison is case-sensitive.

If you want to save any changes you have made to the record that was current prior to calling FINDNEXT or FINDPREV, use the UPDATE function. Otherwise, if the search is successful, any changes made to that record are lost when FINDNEXT or FINDPREV moves to another record.

Here are some examples:

Example 1
FINDPREV('abc') /* Finds 'abc', 'ABC', 'ABc' and so on */
Example 2
FINDNEXT('abc',1,10,'CASE') /* Finds 'abc', but not 'ABC', 'ABc' and so on */