Examples of Some Data Reconfigurations
The following are examples of replacement rule types for specifically needed applications.
Literal Insertion
To insert a literal, separate the left-hand-side terms for its insertion on the right.
a(A:10),b(A:70)->(a),(E'LIT':3),(b)
The 80 ASCII characters are emitted in the output area with the EBCDIC literal LIT inserted after the first 10 ASCII characters.
Deletion
Terms on the left are separated so that the right side may omit unwanted terms.
(B:7),a(A:10)->(Ev(a):L(a))
Only the 10 ASCII characters are emitted (as EBCDIC) in the output area, the 7 binary digits are discarded.
Spacing in the Output Buffer
Where a pre-formatted output buffer exists (typically a display buffer) spacing can be realized by omitting the replication and value functions from a term on the right.
a(A:74)->(E:6),(Ev(a):74)
The (E:6) causes 48 bit positions to be skipped over in the output area, then the 74 ASCII characters are converted to EBCDIC and emitted at the current output position.
Arbitrary Lengths
Some devices/programs generate a variable number of characters per line and it is desirable to produce fixed-length records from them.
a(A:#) -> (Ev(a):74)
The ASCII characters are truncated or padded as required and converted to EBCDIC in a 74 character field.
Transposition
Fields to be transposed should be isolated as terms on the left.
a(X:2),b(A:#)->(Ev(b):L(b)),(a)
String Length Computation
Some formats require the string length as part of the data stream. This can be accomplished by the length function.
a(E:10),b(X'FF':2)->(BL(a)+L(b)+8:8),(Av(a):L(a)),(b)
The length term is emitted first, in a 8 bit field. In this case the length includes the length field as well as the ASCII character field.
Expansion and Compression of repeated Symbols
The following rule packs repeated symbols.
a(E:1), b(E#*v(a):L(b)) -> (BL(b)+1:8),(a)
Given the input string below, three successive applications of the rule will emit the output string shown.
Input: XXXXYYZZZZZZZ
Output: 4X2Y7Z