:PROCESS... :TERM_PROCESS... :ENDPROCESS
Use the :PROCESS and :ENDPROCESS script statements to define the beginning and end of a loop that processes a data sequence line by line. A data sequence holds the contents of a sequential file or the text output of a command. A new line is read in each cycle until the loop finishes or is explicitly terminated with the :TERM_PROCESS statement.
Important! An empty data sequence means that no processing takes place inside the loop — no error message is produced.
To reuse the script variable that holds the data sequence reference, discard the data sequence with :CLOSE_PROCESS before assigning a new value to it. Use GET_PROCESS_LINE to retrieve the content of a specific line in the data sequence.
More information:
Syntax
: PROCESS Data sequence reference [Statement]
: TERM_PROCESS
: ENDPROCESS
: CLOSE_PROCESS
Parameters
| Parameter | Description | Format |
|---|---|---|
| Data sequence reference | Reference to the data sequence to process | Script variable |
| Statement
(Optional) |
One or more script statements executed during every cycle of the loop | n.a. |
| :TERM_PROCESS | Exits the processing loop before the data sequence is fully consumed | n.a. |
| :ENDPROCESS | Marks the end of the processing loop | n.a. |
| :CLOSE_PROCESS | Discards the data sequence and frees the reference variable for reuse. For more information, see :CLOSE_PROCESS. | n.a. |
Examples
The following example retrieves the directory listing of a disk drive and writes each line to the activation report. The loop is terminated early if the &USER# variable contains a specific value.
: SET &HND# = PREP_PROCESS ("PC01", "WINCMD", "*DIR*", "CMD=DIR C:")
: PROCESS &HND#
: SET &LINE# = GET_PROCESS_LINE (&HND#)
: IF &USER# = "TSOS"
: TERM_PROCESS
: ENDIF
: PRINT &LINE#
: ENDPROCESS
: CLOSE_PROCESS &HND#
See also: