RESET Examples

Except for the actual operation performed on the fields, the considerations shown in the following examples also apply to the CLEAR operation. Figure 368 shows an example of the RESET operation with *NOKEY.

Figure 368. RESET Operation with *NOKEY
*...1....+....2....+....3....+....4....+....5....+....6....+....7...+....
FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords++++++++++++++++++++++++++++
EXTFILE   O    E             DISK
DName+++++++++++ETDsFrom+++To/L+++IDc.Functions+++++++++++++++++++++++++++
 * The file EXTFILE contains one record format RECFMT containing
 * the character fields CHAR1 and CHAR2 and the numeric fields
 * NUM1 and NUM2.  It has keyfields CHAR2 and NUM1.
D
D DS1             DS
D  DAY1                   1      8    INZ('MONDAY')
D  DAY2                   9     16    INZ('THURSDAY')
D  JDATE                 17     22
D
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq...
 *
 * The following operation sets DAY1, DAY2, and JDATE to blanks.
C
C                   CLEAR                   DS1
C
 * The following operation will set DAY1, DAY2, and JDATE to their
 * reset values of 'MONDAY', 'THURSDAY', and UDATE respectively.
 * The reset value of UDATE for JDATE is set in the *INZSR.
C
C                   RESET                   DS1
C
 * The following operation will set CHAR1 and CHAR2 to blanks and
 * NUM1 and NUM2 to zero.
C                   CLEAR                   RECFMT
 * The following operation will set CHAR1, CHAR2, NUM1, and
 * NUM2 to their reset values of 'NAME', 'ADDRESS', 1, and 2
 * respectively. These reset values are set in the *INZSR.
 *
C                   RESET                   RECFMT
 * The following operation sets all fields in the record format
 * to blanks, except the key fields CHAR2 and NUM1.
 *
C     *NOKEY        RESET     *ALL          RECFMT
C                   RETURN
C
C     *INZSR        BEGSR
C                   MOVEL     UDATE         JDATE
C                   MOVEL     'NAME    '    CHAR1
C                   MOVEL     'ADDRESS '    CHAR2
C                   Z-ADD     1             NUM1
C                   Z-ADD     2             NUM2
C                   ENDSR
ORCDNAME+++D...N01N02N03EXCNAM++++........................................
O..............N01N02N03FIELD+++++++++.B..................................
ORECFMT    T
O                       CHAR1
O                       CHAR2
O                       NUM1
O                       NUM2
Figure 369. DDS for EXTFILE
     A          R RECFMT
     A            CHAR1         10A
     A            CHAR2         10A
     A            NUM1           5P 0
     A            NUM2           7S 2

Figure 370 shows an excerpt of a source listing for a program that uses two externally described files, RESETIB and RESETON. Each has two record formats, and each record format contains an input field FLDIN, an output field FLDOUT, and a field FLDBOTH, that is input-output capable. The DDS are shown in Figure 371 and Figure 372.

Because RESETIB is defined as a combined file, the fields for RECBOTH, which are defined as input-output capable, are available on both input and output specifications. On the other hand, the fields for RECIN are on input specifications only.

Figure 370. RESET with *ALL – Source Listing Excerpt. The input and output specifications with '=' after the listing line number are generated by the compiler.
     1  * The file RESETIB contains 2 record formats RECIN and RECBOTH.
     2 FRESETIB   CF   E             WORKSTN
     3  * The file RESETON contains 2 record formats RECOUT and RECNONE.
     4 FRESETON   O    E             WORKSTN
     5
     6=IRECIN
     7=I                             A    1    1  *IN02
     8=I                             A    2   11  FLDIN
     9=I                             A   12   21  FLDBOTH
    10=IRECBOTH
    11=I                             A    1    1  *IN04
    12=I                             A    2   11  FLDIN
    13=I                             A   12   21  FLDBOTH
    14 C                   WRITE     RECOUT
    15 C                   WRITE     RECBOTH
    16 C                   READ      RECIN                              ----99
    17 C                   READ      RECBOTH                            ----99
    18
    19  * RESET without factor 2 means to reset only those fields which
    20  * appear on the output specifications for the record format.
    21  * Since only RECOUT and RECBOTH have write operations, the
    22  * RESET operations for RECNONE and RECIN will have no effect.
    23  * The RESET operations for RECOUT and RECBOTH will reset fields
    24  * FLDOUT and FLDBOTH.  FLDIN will not be affected.
    25 C                   RESET                   RECNONE
    26 C                   RESET                   RECIN
    27 C                   RESET                   RECOUT
    28 C                   RESET                   RECBOTH
    29
    30  * RESET with *ALL in factor 2 means to reset all fields.  Note
    31  * that this can only be done when all fields are used in at least
    32  * one of the ways they are defined (for example, an output-capable
    33  * field must be used for output by the record format)
    34  * Since RECNONE does not have either input or output operations,
    35  * the RESET *ALL for RECNONE will fail at compile time.
    36  * Since RECIN does not have any output operations, RESET *ALL RECIN
    37  * will fail because FLDOUT is not output.
    38  * Since RECOUT does not have any input operations, and is not defined
    39  * as input capable on the file specification, RESET *ALL RECOUT
    40  * will fail because FLDIN is not input.
    41  * The RESET *ALL for RECBOTH will reset all fields: FLDIN, FLDOUT
    42  * and FLDBOTH.
    43 C                   RESET     *ALL          RECNONE
    44 C                   RESET     *ALL          RECIN
    45 C                   RESET     *ALL          RECOUT
    46 C                   RESET     *ALL          RECBOTH
    47
    48 C                   SETON                                        LR----
    49=ORECBOTH
    50=O                       *IN14                1A CHAR        1
    51=O                       FLDOUT              11A CHAR       10
    52=O                       FLDBOTH             21A CHAR       10
    53=ORECOUT
    54=O                       *IN13                1A CHAR        1
    55=O                       FLDOUT              11A CHAR       10
    56=O                       FLDBOTH             21A CHAR       10

When the source is compiled, several errors are identified. Both RECNONE and RECIN are identified as having no output fields. The RESET *ALL is disallowed for all but the RECBOTH record, since it is the only record format for which all fields appear on either input or output specifications.

Figure 371. DDS for RESETIB
     A          R RECIN                     CF02(02)
     A            FLDIN         10A  I  2  2
     A            FLDOUT        10A  O  3  2
     A  12        FLDBOTH       10A  B  4  2
     A          R RECBOTH                   CF04(04)
     A            FLDIN         10A  I  2  2
     A            FLDOUT        10A  O  3  2
     A  14        FLDBOTH       10A  B  4  2
Figure 372. DDS for RESETON
     A          R RECNONE                   CF01(01)
     A            FLDIN         10A  I  2  2
     A            FLDOUT        10A  O  3  2
     A  11        FLDBOTH       10A  B  4  2
     A          R RECOUT                    CF03(03)
     A            FLDIN         10A  I  2  2
     A            FLDOUT        10A  O  3  2
     A  13        FLDBOTH       10A  B  4  2


[ Top of Page | Previous Page | Next Page | Contents | Index ]