Contents | Index | < Browse | Browse >
Parsing is an operation that extracts substrings from a string and assigns them to variables. Parsing is performed using the PARSE instruction or its variants ARG and PULL . Parsing is controlled by a template, and there are two basic template objects:
-MARKERS: Absolute, Relative, and Pattern markers
-TARGETS: usually specified by variable symbols. A placeholder is a
special symbol denoted by a period.

Parsing by tokenization:
When a variable is followed immediately by another variable, the value string is determined by breaking the input string into words separated by blanks. Each word is assigned to a variable in the template. Values determined by tokenization will never have leading or trailing blanks. Normally the last variable in the template receives the untokenized remainder of the input string. A placeholder symbol, a period (.), when present serves to accept the remainder of the string, except that it isn't actually assigned a value.

Parsing by position:
If the fields in the input string have known positions, value strings can be specified by absolute or relative positions, indicated as + or - numbers.

Program Example:

/*Example of parsing by position */

/*Record format looks like:
Start: 1-5
Length: 6-10
Data itself found at (start,length)
*/

Record='0001100016Shake and bake!!'
PARSE value record with 1 start +5 length +5 = start Data +length
say 'Start:' start
say 'Length:' Length
say 'Data field: ' Data

Program output:
Start: 00011
Length: 00016
Data field: Shake and bake!!