IBM SC34-5764-01 Server User Manual


 
Templates Containing Positional (Numeric) Patterns
A positional pattern is a number that identifies the character position at which to split data in the source
string. The number must be a whole number.
An absolute positional pattern is
v A number with no plus (+) or minus (-) sign preceding it or with an equal sign (=) preceding it
v A variable in parentheses with an equal sign before the left parenthesis. (See page 209 for details on
variable positional patterns.)
The number specifies the absolute character position at which to split the source string.
Here is a template with absolute positional patterns:
variable1 11 variable2 21 variable3
The numbers 11 and 21 are absolute positional patterns. The number 11 refers to the 11th position in the
input string, 21 to the 21st position. This template:
v Puts characters 1 through 10 of the source string into variable1
v Puts characters 11 through 20 into variable2
v Puts characters 21 to the end into variable3.
Positional patterns are probably most useful for working with a file of records, such as:
character positions:
11121 40
┌──────────┬──────────┬────────────────────┐end of
FIELDS: │LASTNAME │FIRST │PSEUDONYM │record
└──────────┴──────────┴────────────────────┘
The following example uses this record structure.
/* Parsing with absolute positional patterns in template */
record.1='Clemens Samuel Mark Twain '
record.2='Evans Mary Ann George Eliot '
record.3='Munro H.H. Saki '
do n=1 to 3
parse var record.n lastname 11 firstname 21 pseudonym
If lastname='Evans' & firstname='Mary Ann' then say 'By George!'
end /* Says 'By George!' after record 2 */
The source string is first split at character position 11 and at position 21. The language processor assigns
characters 1 to 10 into lastname, characters 11 to 20 into firstname, and characters 21 to 40 into
pseudonym.
The template could have been:
1 lastname 11 firstname 21 pseudonym
instead of
lastname 11 firstname 21 pseudonym
Specifying the 1 is optional.
Optionally, you can put an equal sign before a number in a template. An equal sign is the same as no sign
before a number in a template. The number refers to a particular character position in the source string.
These two templates work the same:
lastname 11 first 21 pseudonym
lastname =11 first =21 pseudonym
Parsing
206
CICS TS for VSE/ESA: REXX Guide