Accessing Arrays in Advantage UFO
search cancel

Accessing Arrays in Advantage UFO

book

Article ID: 65605

calendar_today

Updated On:

Products

UFO

Issue/Introduction


Accessing Arrays in UFO

Environment

Release:
Component: UFO

Resolution

By: Level 2 Technical Support

UFO provides the ability to access arrays. Arrays can be defined in an UFO File Definition Screen (FDS) associated with an UFO MODE=2 Display Definition (Mode-2 DD). Examples of an FDS and Mode-2 DD are provided in this article. Note: Arrays can also be defined in an UFO MODE=1 Display Definition (Mode-1 DD).

Below is an example of an UFO FDS for a record composed of a 10-byte character field KEY and an array MYARRAY. MYARRAY is an array that is composed of a 10-byte zoned field (LEN = 10 and TYPE F = Z) that occurs 12 times (OC # = 12). The length specification, LEN, is the number of display characters of a single occurrence of the array. The start position, START, is the beginning location of the first occurrence of the field.

UFOFDS           REVIEW/UPDATE/CREATE FDS ENTRIES          FUNCTION--> *

DSD NAME: MYARRAY
**NAME** ***********DESCRIPTION********* TYP LEN START ATT D EDIT OC STA
F U F D P CD F # TUS
KEY KEYFIELD C 10 1 0 8 0 00 01
MYARRAY TWELVE OCCURS OF MY ARRAY Z 10 11 0 8 0 00 12

Below is an example of the related UFO Mode-2 DD for the above FDS.

UFODD    REVIEW/UPDATE/CREATE MODE=2 DISPLAY DEFINITIONS   FUNCTION--> *

DISPLAY.. MYARRAY STATUS. VML.. 1.05 DATE CHANGED 02/28/03
CONTINUED ALARM.. N AUTH. TIME CHANGED 15:35:31.8
CURSOR... TERMINAL.... U066
PROCEDURE MYPROC DDXNAME MYARRAY OPERATOR....
ROW COL FOR- **NAME** ********* DESCRIPTION ********* US- F R ATT EDIT T
MAT AGE # # F D CD F F
01 1 1 F TESTING OUT ARRAY PROCESSING 0 0 0 8 00
02 5 1 MYARRAY ARRAY 0 0 0 8 00

An array can be accessed in an UFO Procedure Definition Screen (PDS). In order to access the elements in an array, an index must be defined and controlled using the SETINDEX command. The index can be either a work or a data field, and it must be defined as a 2-byte binary field (length 3, 4 or 5). The SETINDEX command establishes an association between the array element and its index. When referring to an array field, the index value must be greater than zero and less than or equal to the number of occurrences in the array. Also, the SETINDEX command must be coded to set the index value for each UFO cycle, but need only be done once per cycle.

The UFO PDS below illustrates how to initialize the elements (with zoned zeros) in the array MYARRAY in the UFO Post Read Screen (PRS) cycle.

UFOPDS                  CREATE/UPDATE/REVIEW PROCEDURES                *

Proc.: MYPROC 1.04 Cont.: Prg: Sta:
The 02/28/03 At 13:11:37.8 On U075
Label= Cmd = -- 1 -- OP == 2 == 'GOTO' -----|TL ...0 Str ....0 Sts ....0
01 ONPRS SET
02 EXIT
03 SET SETINDEX INDEX TO MYARRAY
04 MOVE 1 TO INDEX
05 WHILE INDEX LE 12
06 MOVE /ZERO TO MYARRAY
07 COUNT INDEX
08 ENDWHILE
09 EXIT

Read More About It

For more information on array processing, see the UFO Application Programmer Guide.

Contribute Your Ideas

If you have a tried and true technique that you would like to share with the UFO community as a published article, please contact UFO Technical Support