PARSE Instruction
The PARSE instruction takes one or more source strings and then parses them using the template for directions. The process of parsing is one where parts of a source string are extracted and stored in variables. Which parts exactly is determined by the patterns
PARSE [ UPPER ] type [ template ] ;
type is defined as:
{ ARG | LINEIN | SOURCE | VERSION |
VALUE [ expr ] WITH VAR symbol }
Which strings are to be the source of the parsing is defined by the type sub-clause:
- ARG
- The data to use as the source during the parsing is the argument strings given at the invocation of this procedure level. Note that this is the only case where the source may consist of multiple strings.
- LINEIN
- Makes the PARSE instruction read a line from the standard input stream as if the LINEIN() built-in function had been called. It uses the contents of that line (after stripping off end-of-line characters if necessary) as the source for the parsing. This may raise the NOTREADY condition if problems occur during the read.
- SOURCE
- The source string for the parsing is a string containing information about the invocation of the program. This information will not change during the execution of a tcSCRIPT script. The format of the string is: system invocation filename
- VALUE expr WITH
- This form evaluates expr and uses the result of that evaluation as the source string to be parsed. The token WITH may not occur inside expr, because it is a reserved keyword in this context.
- VAR symbol
- This form uses the current value of the named variable symbol (after tail-substitution) as the source string to be parsed. The variable may be any variable symbol. If the variable is uninitialized, a NOTREADY condition will be raised.
- VERSION.
- This form resembles SOURCE. It will display information about tcSCRIPT.The following example shows a typical output:
PARSE VERSION info SAY info tcSCRIPT 5.0.1161 (STR), 32-bit, tcREXX 1.1.266