• Aucun résultat trouvé

FORMI NG TABLES AND ARRAYS

Dans le document RPG II (Page 104-107)

RECORD TYPE ACCOUNT NUMBER

TREATMENT TREATMENT

CODE PRICE

2 800

19 2100

38 750

39 200

· · ·

· · ·

· · ·

99 1700

o

RELA TED TABLES

Figure 12-1. A Use for Related Tables

FORMI NG TABLES AND ARRAYS

Tables and arrays may be formed inside or outside the computer. Elements formed on the outside may be entered through any input device. Any computer program, including an RPG II program, may also form them, and they· may be output to any sequential file medium. Tables and arrays have the same format and structure rules whether they are formed inside or outside the computer. The complete set of entries comprising a table or array is considered a sequen-tially organized file, although the entries need not be in sequence within a table or array.

must not be confused with the table or array name described earlier in this section. Table and array files may be assigned to the same device and even have the same filename if they are read from the same device. Table and array files are read in the order the tables and arrays are specified on form E.

A table or array file must have a unique name consistent with the file naming rules listed in section 1. The filename

COMPI LATION TIME

When tables and arrays are loaded at compilation time or pre-execution time, the entire table or array is loaded before the first input record is read by the object program.

I

• • • 99

.01700

DEFINED SEPARATEL Y

TREATMENT PRICE TABLE

TREATMENT CODE TABLE

TREATMENT CODE AND PRICE TABLE

T ABLES DEFINED WITH ALTERNATING FORMAT

Figure 12-2. Two Methods for Defining Related Tables Compilation time. tables and arrays are compiled along with

the source program, come from the same input stream as the source program, and, thus, do not have a From Filename column entry on the Extension Specifications sheet. Here are the rules for entering a compilation time table or array,

The table or array must be on the same device that holds the source program and must follow the RPG II source program, file translation tables, and alternate collating sequence records, if any.

Each distinct table or array must be· preceded by a record having **kS in positions 1, 2, and 3. As this record is a delimiter, the first element of a table or array record must not contain those characters in the first three positions.

The last compilation time table or array is followed by a record reading /*~in positions 1,2, and 3.

• The tables and arrays must be loaded in the same order as described on the Extension Specification sheet.

• Compilation time tables and arrays must have entries in columns 33 through 35 (Number of Entries Per Record) and must not have entries in columns 11 through 18 (From Filename) on the Extension Specification sheet.

• Numeric tables and arrays must be in unpacked decimal format.

The proper placement of compilation time tables and arrays in the compiler input stream is illustrated in figure 12-3. In this example, the user has a file translation table, alternate collating sequence records, and two of his own compilation time arrays, ARRX and ARRY. The file translation table and alternate collating sequence records are optional and because of that are illustrated with broken lines. If either a file translation table or an alternate collating sequence, but not both, is included, it must precede the user's tables and arrays. If both are included, the file translation table must precede the alternate collating sequence, as shown in the illustration.

NOTE: ~ = BLANK 0310

Figure 12-3. Placement of Compilation Time Tables and Arrays

PRE-EXECUTION TIME EXECUTION TIME

Pre-execution tables and arrays are not part of the source program. They are used by the program like any other data file. They differ from execution time tables and arrays, however, because they are loaded by RPG II prior to execution of the object program.

Here are the rules for loading pre-execution time tables and arrays:

• A record containing 1* in positions 1 and 2 must follow each pre-execution time table or array.

• Pre-execution time tables and arrays must be arranged in the same order they are described in the extension speci fications.

• A pre-execution time table or array must have entries in columns 11 through 18 (From Filename) and 33 through 35 (Number of Entries Per Record) of the Extension Specifications, and may have entries in columns 43 and 55 (Packed or Binary Field), if appro-priate.

Execution time table and array files are read by the object program and can only be described as any other input file on form I. The definition on form I specifies whether the file has a single record or many records, and whether or not the elements are contiguous in a record. If the unindexed array name appears as the field name on form I, then the array is contained in one record and the elements are contiguous. If the elements are not contiguous, each element must be specified on its own form I line, with the appropriate field positions specified.

Such a table or array may not be used until every element that is required for program execution is in core. Calcula-tion and output operaCalcula-tions, therefore, may have to be suspended for several program cycles until the object program has read all of the records from the file.

The extension and input specifications required to fill an execution time array from contiguous elements of a single input record are shown in figure 12-4. Using the same

g~

CONTRPL DATA RPG EXTENSION AND LINE COUNTER SPECIFICATIONS Printed in U.S.A.

CORrQRt\TlON

1 2 75 76 71 78 79 BO

Progr ....

P.~Of_ :::r:.tion

I I I I I I I

Progrernmer Date

Extension Specifications

E

Record Sequence of 1he Chaining File

Number

Number of 1M Q\aInIng Field of Number I!!- Table or

~

Table or EntrIeo of ~

:1

~ ATrayName length Comments

Una

!

ToFllllfllme

ATriy Name

....

Entri .. of of

Record P.-Table Entry

Dans le document RPG II (Page 104-107)

Documents relatifs