Move text between an array and a scalar field
For fixed-width text, two equal-length groups can hold the same characters in different layouts. The example uses one 50-character field in one group and 50 one-character occurrences in the other.
Initialize an alpha array
CNV TEXT can address all receiving occurrences of an alpha field with occurrence 000. It performs a text conversion, so use a group assignment instead when you need to preserve the original layout. * initialize an Alpha Array:
*
SET --- TEMP 1 =
CNV TEXT OPT WORK TEST ARRAY 000 = --- TEMP 1
Copy the group layout
Define the two equal-length groups in a Working Storage file.100 WS GROUP1 GROUP HEADER 1 200 WS A50 ALPHA 1 X(50) 300 WS GROUP1 END GROUP TRAILER 1 400 WS GROUP2 GROUP HEADER 1 500 WS A1 50 ALPHA 1 X(1) Oc 50 600 WS GROUP2 END GROUP TRAILER 1Put the text in the scalar field, then copy its whole group to the group containing the array.
SET PAT WS A50 = XYZ
SET PAT WS GROUP2 = PAT WS GROUP1
Read the individual occurrences. The first three hold X, Y and Z.
Appl Field Name Occ Field Value
PAT WS A1 50 001 X
PAT WS A1 50 002 Y
PAT WS A1 50 003 Z
Don't forget the ability to search for individual characters (ex: commas or quotes) in ILF code, by means of the IF INCLUDES ('IF' verb with 'IN' operator) or Regular Expresssions ('IF' verb with 'RS' or 'RI' operator).