HP 3000 Manuals

Operation Definitions (Cont.) [ HP RPG/iX Reference Manual ] MPE/iX 5.0 Documentation


HP RPG/iX Reference Manual

Operation Definitions (Cont.) 

PUTJW 

This system operation locates a JCW in the system JCW table and changes
its value.  If the JCW does not exist, a new one is created.  PUTJW uses
the system intrinsic PUTJCW.

To use PUTJW, enter the value to place in the JCW in the Factor 1 Field.
You can use a numeric literal or field.  It must be no more than 8 digits
long with no decimal places.  It must contain a number in the range,[REV
BEG] 0-65,535.[REV END] If the value is outside of this range, the
run-time error "Invalid Numerical Data" is printed.  Enter the name of
the JCW you want to locate in the Factor 2 Field.  If the JCW does not
exist, a new one is created with this name.  The name can be contained in
an alphanumeric variable or literal.  It must begin with a letter.  Leave
the Result Field blank.

You must enter at least one indicator in the Resulting Indicators Field
(columns 54-59).  When PUTJW is executed, the indicators are set to
indicate the outcome of the operation.  If the indicator in the High
Subfield is ON, there is no more room in the JCW table for the new entry.
If the indicator in the Low Subfield is ON, the JCW name that you entered
does not begin with a letter.  If the JCW was found and altered
successfully, or if a new JCW was created, the indicator in the Equal
Subfield is turned ON.

READ 

This file operation reads a record from a sequential demand file (that
may or may not reside on a SPECIAL device) or a full procedural file.
The record is made available during the present cycle instead of the next
one (FORCE makes a record available during the next cycle).  READ is
similar to CHAIN except that CHAIN processes files randomly.

To use READ, leave the Factor 1 Field blank and enter the name of the
demand or full procedural file in the Factor 2 Field.  Leave the Result
Field blank.

You can enter an indicator in the Equal Subfield (columns 58-59).  It is
turned ON when end-of-file is encountered.  If you do not enter an
indicator, the H0 indicator is turned ON. Do not use the High and Low
Subfields (columns 54-57).  Do not use control level indicators, matching
fields, or look-ahead fields for the file.  Also, do not specify
sequence-checking for the file in the Input Specification.

When READ is executed, the appropriate record-identifying indicators are
turned ON and the input fields are made available.  Unidentified record
types cause run-time errors.

Example 

Figure 8-36 shows how to read the demand file SURTAX (see line 1).  The
file is read only when indicator 07 is ON.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C                     MOVE TAX2      NETAXP                          |
|            C           NETAXP    COMP 15000                07                   |
|     1     C  07                 READ SURTAX                                     |
|                                                                                 |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-36.  Reading a Demand File 

READE 

This file operation reads the next record from an indexed demand file or
a full procedural file.  If the record key matches the Factor 1 Field,
the record is made available for processing.

To use READE, enter the name of the field that contains the key value in
the Factor 1 Field.  Enter the name of the demand or full procedural file
in the Factor 2 Field.  Leave the Result Field blank.

You can enter an indicator in the Equal Subfield (columns 58-59).  It is
turned ON when the record key matches the Factor 1 Field and when
end-of-file is encountered.  If you do not enter an indicator, the H0
indicator is turned ON when the record key does not match the Factor 1
Field or when end-of-file is encountered.  Do not use the High and Low
Subfields (columns 54-57).  Do not use control level indicators, matching
fields, or look-ahead fields for the file.  Also, do not specify
sequence-checking for the file in the Input Specification.

When READE is executed, the appropriate record-identifying indicators are
turned ON and the input fields are made available.  Unidentified record
types cause run-time errors.

READP 

This file operation reads the previous record from a sequential or
indexed demand or full procedural file.  If the file is indexed, the
previous record is read by key (not chronologically).

To use READP, leave the Factor 1 Field blank and enter the name of the
demand or full procedural file in the Factor 2 Field.  Leave the Result
Field blank.

You can enter an indicator in the Equal Subfield (columns 58-59).  It is
turned ON when the beginning of the file is encountered.  (If you do not
enter an indicator, the H0 indicator is turned ON) Do not use the High
and Low Subfields (columns 54-57).  Do not use control level indicators,
matching fields, or look-ahead fields for the file.  Also, do not specify
sequence-checking for the file in the Input Specification.

When READP is executed, the appropriate record-identifying indicators are
turned ON and the input fields are made available.  Unidentified record
types cause run-time errors.
[REV BEG]

RESET 

This file operation sets a file to its initial open condition.  This
operation allows you to process a file more than once without restarting
the program.

The file must be specified in the File Specification as an INPUT or
UPDATE type with a designation of DEMAND or FULL PROCEDURAL. The file can
be an MPE (flat) file, a KSAM file, or a TurboIMAGE file.  You can read a
file sequentially until its end-of-file indicator is set (or end-of-chain
for TurboIMAGE chained sequential files), and then use this indicator to
condition the RESET operation to set the file to its initial state.

For MPE and KSAM files, RESET calls the MPE intrinsic FCONTROL with a
parameter of 5 (refer to the MPE/iX Intrinsics Reference Manual), and for
TurboIMAGE files, RESET does a DBCLOSE mode 3 (refer to the TurboIMAGE/iX 
Database Management System manual).  For KSAM files, FCONTROL parm 5
resets to the lowest primary key, so this operation is not allowed if you
are reading the file chronologically (file specification column 32 is C).

To use RESET, leave the Factor 1 Field blank and enter the name of the
file you want to reset in the Factor 2 Field.  Leave the Result Field
blank.  Enter an indicator in the High Subfield (columns 54-55); this is
turned ON if the RESET operation fails.  Do not use the Low or Equal
Subfields (columns 56-59), the decimal positions field (column 52), or
the half-adjust field (column 53).
[REV END]

RLABL 

This external subroutine operation names a field, table, array, or
indicator to be passed to an external subroutine.  RLABL is used in
conjunction with the EXIT operation.[REV BEG] Note that you cannot use or
set indicators in external procedures such as user-trap routines that are
not executed with the EXIT operation.[REV END]

Enter the field, table, array, or general indicator (01-99) in the Result
Field.  To pass an indicator, enter it in this format:  INxx.  For
instance, indicator 01 is entered as IN01.  If the program has other
external routines that use the field, array, or indicator, define it only
once using RLABL. Do not enter the same name used in RLABL operations
with a GOTO, TAG, BEGSR, or ENDSR operation elsewhere in the program.

In the external subroutine, declare all fields, tables and arrays (passed
from the RPG main program) as external character arrays and all
indicators as external integers.  The indicators contain zero when they
are OFF and one when they are ON. Be sure the names for fields, tables,
arrays, and indicators passed to the external subroutine are the same as
those in the RPG program.

Example 

Figure 8-37 shows how to use the EXIT operation to call an external
subroutine and how to use the RLABL operation to exchange information
with it.

The program reads two numbers (FLD1 and FLD2) and a six-character string
(FLD3) from a disk file.  It then calls the external subroutine EXSUB in
line 3.  EXSUB is written in COBOL and is shown in figure 8-38.  It adds
the fields passed to it as parameters (FLD1 and FLD2 starting in line 1)
and displays the result.  It also displays FLD3.  If the result of the
ADD is zero, indicator 22 is turned on.  The result (RESLT1) along with
FLD1, FLD2, and indicator 22 are returned to the RPG program when EXSUB
finishes.  The second external subroutine EXSUB2 is then called in line
4.  EXSUB2 is written in C and is shown in figure 8-39.  Indicator 22 and
the field FLD3 are passed to it as parameters (starting at line 2).
Depending on whether indicator 22 is ON or OFF, EXSUB2 moves FLD3 to the
field RESLT2 or clears RESLT2 to blanks.  It then returns to the RPG
program.  The RPG program writes the input fields FLD1 and FLD2 and the
fields (RESLT1 and RESLT2) created by the external subroutines to the
output file OUTFLE.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            FINFILE  IP  F      80            DISK                               |
|            FOUTFLE  O   F      50            DISK                               |
|                                                                                 |
|            IINFILE  AA  01   1 CO                                               |
|            I                                        3   80FLD1                  |
|            I                                        9  140FLD2                  |
|            I                                       15  20 FLD3[REV BEG]         |
|            I        NS[REV END]                                                 |
|     1     C                     RLABL          FLD1                             |
|            C                     RLABL          FLD2                            |
|            C                     RLABL          RESLT1  70[REV BEG]             |
|     2     C                     RLABL          IN22[REV END]                    |
|            C                     RLABL          FLD3                            |
|            C                     RLABL          RESLT2  6[REV BEG]              |
|            C                     SETOF                     22                   |
|     3     C                     EXIT EXSUB[REV END]                             |
|     4     C                     EXIT EXSUB2                                     |
|            C   22      "MOVED"   DSPLY                                          |
|                                                                                 |
|            OOUTFLE  D        01                                                 |
|            O                                    5 "FLD1="                       |
|            O                         FLD1      11                               |
|            O                                   17 "FLD2="                       |
|            O                         FLD2      23                               |
|            O                                   31 "RESULT="                     |
|            O                         RESLT1    38                               |
|            O                                   44 "FLD3="                       |
|            O                         RESLT2    50                               |
|                                                                                 |
|                                                                                 |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-37.  Using EXIT, RLABL, and External Subroutines 
_____________________________________________________________________________________
|                                                                                   |
|        001000$CONTROL SUBPROGRAM                                                  |
|        001100 IDENTIFICATION DIVISION.                                            |
|        001200 PROGRAM-ID.  EXSUB.                                                 |
|        001300 ENVIRONMENT DIVISION.                                               |
|        001400 DATA DIVISION.                                                      |
|        001500 WORKING-STORAGE SECTION.                                            |
|        001520 01 FLD1 EXTERNAL PIC S9(6) COMP-3.                                  |
|        001530 01 FLD2 EXTERNAL PIC S9(6) COMP-3.                                  |
|        001532 01 RESLT1 EXTERNAL PIC S9(7) COMP-3.                                |
|        001534 01 FLD3 EXTERNAL PIC X(6).                                          |
|        001540 01 IN22 EXTERNAL PIC S9(9) COMP.                                    |
|        001550    88 IND-22-ON  VALUE 1.                                           |
|        001600 PROCEDURE DIVISION.                                                 |
|        001700 START-IT.                                                           |
|        001800        ADD FLD1 FLD2 GIVING RESLT1.                                 |
|        001810        DISPLAY "FLD-1 = " FLD1, "FLD-2 = " FLD2, "RESULT = " RESLT1.|
|        001820        DISPLAY "FLD-3 = " FLD3.                                     |
|        001830        IF RESLT1 IS EQUAL TO 0                                      |
|        001840           SET IND-22-ON TO TRUE.                                    |
|        001850        GOBACK.                                                      |
|                                                                                   |
|                                                                                   |
|                                                                                   |
|                                                                                   |
_____________________________________________________________________________________

          Figure 8-38.  The External Subroutine EXSUB Written in COBOL 
_______________________________________________
|                                             |
|            extern char fld3[];              |
|            extern char reslt2[];[REV BEG]   |
|            extern int in22;[REV END]        |
|         exsub2 ()                           |
|         {                                   |
|            if (in22)                        |
|               strncpy (reslt2, fld3, 6)     |
|            else                             |
|               strncpy (reslt2, "      ", 6);|
|         }                                   |
|                                             |
|                                             |
|                                             |
_______________________________________________

          Figure 8-39.  The External Subroutine EXSUB2 Written in C 

SET 

This display operation enables the function keys (f1 through f8) on the
keyboard.  Once enabled, they can be used with the DSPLY and DSPLM
operations to set the function key indicators.  If you have a terminal
that supports the function key labeling feature, you can also use this
operation to label the function keys.[REV BEG] See Chapter 11, "The RPG
Screen Interface (RSI)", for information about setting function key
labels for RSI applications.[REV END]

To label the function keys, enter an array name in the Factor 1 Field.
You must define the array in a File Extension Specification.  Each
element of the array defines the text to be displayed on the screen for a
function key.  The array must contain eight elements, each sixteen
characters long.  The first eight characters are displayed in the top
half of the label and the last eight characters are displayed in the
bottom half of the label.

To use function keys with DSPLY or DSPLM, enter up to three function key
indicators in the Resulting Indicators Field (columns 54-59).  To enable
all of the function keys, enter F@ in columns 54-55.  Function keys that
you do not enable are disabled and, when pressed, cause this message to
be displayed:

          Function Key not enabled!

Example 

Figure 8-40 shows how to use SET to enable all of the function keys and
to define the text for their labels.  The SET operation in line 2
identifies the array KEYLBL (line 1) that contains the labels for the
function keys and it also enables the function keys (F@).  In this
particular example, the function keys are used to prompt a user to select
a report to print.  The function key labels are shown below as they
appear in the KEYLBL array.

         Current Detail
         Current Summary
         Y-T-D   Detail
         Y-T-D   Summary
         Compare Detail
         Compare Summary
         MonthEndProcess
         Year-EndProcess

___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     1     E                    KEYLBL  1   8 16                 FUNC KEY LABELS |
|                                                                                 |
|     2     C           KEYLBL    SET                       F@                    |
|                                                                                 |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-40.  Using the SET Opertion 

SETLL 

This file operation sets the lower record limit for sequential read
operations in KSAM and TurboIMAGE demand files.

To condition the operation, enter indicators in either or both the
Control Level Field (columns 7-8) and the Indicators Field (columns
9-17).

Enter a literal or field name in the Factor 1 Field that gives the value
of the lower limit.  The length of Factor 1 must be the same as the key
field length for the file except when you're using partial keys.  You can
use partial (shorter) keys with KSAM files.  If you do, they must be
unpacked fields and you must enter a relational operator in the Result
Field (columns 43-45).  When you use a partial key, RPG gets the first
record whose key (leftmost characters) matches the characters in the
Factor 1 Field.

Enter the file name in the Factor 2 Field.  The file must be a KSAM or
TurboIMAGE demand file.

You may enter one of the following relational operators in columns 43-45
of the Result Field in KSAM files only:

--------------------------------------------------------------------------------------------
|                                    |                                                     |
|  Enter this relational operator:   |              To set the lower limit to              |
|                                    |                record keys that are:                |
|                                    |                                                     |
--------------------------------------------------------------------------------------------
|                                    |                                                     |
| *EQ                                | Equal to Factor 1.                                  |
|                                    |                                                     |
| *GT                                | Greater than Factor 1.                              |
|                                    |                                                     |
| *GE or blank                       | Greater than or equal to Factor 1.                  |
|                                    |                                                     |
--------------------------------------------------------------------------------------------

You can enter an indicator in the High Subfield (columns 54-55) of the
Resulting Indicators Field.  It is turned ON if SETLL fails to locate a
record specified by the relational operator (the Equal Subfield indicator
(columns 58-59) is turned ON by a subsequent READ to the file).

If a status array has been specified for a file, the SETLL operation will
return the status of a DBFIND operation on an image demand file.  This is
useful for finding the length of a chain.  If the information from the
DBFIND is needed later in the program, it should be saved in some other
variables prior to any following READ since the status from its DBGET
will replace that from the DBFIND.

Example 

Figure 8-41 shows how to use the SETLL operation to set the lower record
limit for the file named IFILE. The lower limit is any key value greater
than the value in the field LOWLIM.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C           LOWLIM    SETLLIFILE     *GT                             |
|                                                                                 |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-41.  Using the SETLL Operation 

SETOF 

This indicator and bit setting operation turns OFF the indicators that
you enter in the Resulting Indicators Field (columns 54-59).  You can
enter from one to three indicators in the field.  Do not use the Factor 1
and Factor 2 Fields.

SETON 

This indicator and bit setting operation turns ON the indicators that you
enter in the Resulting Indicators Field (columns 54-59).  You can enter
from one to three indicators in the field.  Do not use the Factor 1 or
Factor 2 Fields.

Example 

Figure 8-42 shows how to use the SETON operation.  Indicators 03 and L2
are turned ON.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C                     SETON                     03L2                 |
|                                                                                 |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-42.  Using the SETON Operation 

SORTA 
[REV BEG]

This array operation arranges array elements into ascending or descending
sequence in both alphanumeric and numeric arrays.[REV END]

Enter the array to be sorted in the Factor 2 Field.  To condition the
operation, enter indicators in the Control Level Field (columns 7-8) or
the Indicators Field (columns 9-17), or both.  Leave all other columns
blank.

If the Table/Array Sequence Field (column 45) of the File Extension
Specification for the array is A or blank, the array is sorted in the
ascending order.  If the Table/Array Sequence Field is D, the array is
sorted in descending order.
[REV BEG]

Alphanumeric arrays are sorted using the ASCII collating sequence.  You
cannot specify an alternate collating sequence.[REV END]

Example 

Figure 8-43 shows how to use SORTA to sort an array in ascending sequence
and in descending sequence.  The array ARSEQ is read from the file
ANYFILE and moved to the array ARSEQA. ARSEQA is then sorted in ascending
sequence in line 1.  ARSEQ is then moved to the array ARSEQD and sorted
into descending sequence in line 2.

Table 8-18 gives an example of the elements in each of the arrays after
line 2 is executed.

          Table 8-18.  Elements when using SORTA 

-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|      Element #:       |        ARSEQ:         |        ARSEQA:        |        ARSEQD:        |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|           1           |        791006         |        470711         |        840315         |
|                       |                       |                       |                       |

|           2           |        470711         |        530820         |        830512         |
|                       |                       |                       |                       |
|           3           |        530820         |        640218         |        791006         |
|                       |                       |                       |                       |
|           4           |        640218         |        791006         |        640218         |
|                       |                       |                       |                       |
|           5           |        830512         |        830512         |        530820         |
|                       |                       |                       |                       |
|           6           |        840315         |        840315         |        470711         |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------

___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            E                    ARSEQ       6  6                                |
|            E                    ARSEQA      6  6  A                             |
|            E                    ARSEQD      6  6  D                             |
|                                                                                 |
|            IANYFILE NS  01                                                      |
|            I                                        1  36 ARSEQ                 |
|     [REV BEG]                                                                   |
|            C   01                MOVE ARSEQ     ARSEQA                          |
|     1     C   01                SORTAARSEQA                                     |
|            C   01                MOVE ARSEQ     ARSEQD                          |
|     2     C   01                SORTAARSEQD[REV END]                            |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-43.  Using the SORTA Operation 

SQRT 

This arithmetic operation computes the square root of Factor 2 and places
it in the Result Field.  You can enter an array name in the Factor 2 and
Result Fields.  When you do this, the square root of each element in the
Factor 2 array is placed in the corresponding element of the Result Field
array.
[REV BEG]

You can use half-adjust with this operation.  But do not use Factor 1,
and do not enter a negative value in Factor 2.  Make sure the number of
decimal positions in the Result Field is not larger than the size of the
Result Field, and do not use resulting indicators.[REV END]

SUB 

This arithmetic operation subtracts Factor 2 from Factor 1 and places the
difference in the Result Field.  If you subtract two fields of the same
value, you effectively set the Result Field to zero.  If Factor 1 is
blank, Factor 2 is subtracted from the Result Field and the difference is
placed in the Result Field.

SUSP 

This system operation immediately suspends execution of the program and
returns control to the parent process (the RPG program must be activated
as a child process by the parent process).  Before the program is
suspended, these actions are performed:

   *   The user indicators (U1-U8) are posted to the system Job Control
       Word (JCW).

   *   The Local Data Area (LDA) is posted to the LDAFILE.

   *   If the program uses a WORKSTN file, the terminal is cleared and
       removed from block mode.  The  BREAK  key is enabled.

When the RPG program is reactivated by the parent process, the actions
listed below take place and the RPG program resumes execution with the
operation following SUSP:

   *   The user indicators (U1-U8) are restored.

   *   The Local Data Area (LDA) is restored.

   *   If the program uses a WORKSTN file, the terminal is set to block
       mode and the previous screen is redisplayed.

To condition the SUSP operation, enter one or more indicators in the
Control Level Field (columns 7-8) and (or) the Indicators Field (columns
9-17).  Enter SUSP in the Operation Field and leave the remaining
specification fields blank.

When a suspended RPG program is resumed, record pointers are not reset.
This means that, if you're processing a file sequentially, the next
record (not the first one in the file) is presented.  For this reason,
you may want to use SUSP only in those programs that process files
randomly.  Also, when using file or record locking, be sure to unlock all
files and records before executing SUSP. You can unlock them by either
forcing a write to the file or by using UNLCK.

Suspending an RPG Program 

There are two ways to suspend an RPG program.  You can suspend the
program when it ends normally or you can suspend the program at any point
in the Calculation Specifications by using the SUSP operation.

The suspend feature is designed for programs that are called from menu
programs and the PROCMON menu processing system.  Suspending saves time
when switching back and forth between a menu program (or PROCMON) and an
RPG program because files remain open and the RPG program does not have
to be reloaded when execution starts again.  When an RPG program ends or
is suspended, control returns to the menu or parent process (the menu
program or PROCMON). The program remains suspended until you specifically
start it again.

To suspend the program when it terminates normally, enter a command to
set "suspend mode", then follow this by a RUN command to start the
program.  The example below shows how to do this:

     :SETJW RPGSUSP=1          Sets "suspend" mode
     :RUN GL45P                Starts execution of GL45P
        .                      This line is executed as soon as GL45P ends
        .
        .
     :RUN GL45P                Starts execution of GL45P at the beginning

If you want to control when the program is suspended, enter a command to
create a process for the RPG program, then activate the process.  The
following lines create a process for the program PAY0680, then activate
(execute) the program.  The program contains a SUSP Calculation
Specification to suspend the program.  Once suspended, the program
"sleeps" until the next ACTIVATE command.  When the program resumes,
execution begins with the operation following SUSP.

     :CREATE PAYO680        Creates process only; does not execute it
     :ACTIVATE PAY0680      Starts RPG program PAY0680
            .               This line is executed after SUSP encountered
            .
            .
     :ACTIVATE PAY0680      Starts PAY0680 with the operation following SUSP

TAG 

This branching operation labels the operation immediately following it.
This allows you to skip to the operation from other places in the
program.

To use TAG, enter it immediately before the operation to which you want
to branch.  Enter a label in the Factor 1 Field.  Do not enter a label
that is used in another TAG operation.  A TAG label can be the same as a
field name.  Do not use the Factor 2 and Result Fields.

If the TAG label is associated with a total-time operation, enter a
control-level indicator in the Control Level Field (columns 7-8).  Do not
enter indicators in the Indicators Field (columns 9-17).

Example 

Figure 8-44 shows how to use GOTO and TAG. The TAG operation in line 1
assigns the label START to the ADD operation that follows it.  When the
ADD operation turns ON indicator 01, the GOTO operation in line 2
branches to the operation whose label is CALCS (line 4).  This branch is
a conditional branch because it occurs only when indicator 01 is turned
ON.

The GOTO operations in lines 3 and 5 are unconditional branches, since no
indicator is used with them.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C                      .                                             |
|            C                      .                                             |
|            C                      .                                             |
|     1     C           START     TAG                                             |
|            C           SUM1      ADD  SUM2      TOTAL  102     01               |
|     2     C   01                GOTO CALCS                                      |
|            C           MXRA      MULT MXRB      PRODCT 102                      |
|     3     C                     GOTO START                                      |
|            C                      .                                             |
|            C                      .                                             |
|            C                      .                                             |
|     4     C           CALCS     TAG                                             |
|            C                      .                                             |
|            C                    (calculations)                                  |
|            C                      .                                             |
|     5     C                     GOTO START                                      |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-44.  Using the GOTO and TAG Operations 

TESTB 

This compare and test operation (TEST Bit) tests the bits in a
one-character, alphanumeric field to determine if they are ON or OFF.
Enter the one-character field to test in the Result Field.  Enter the bit
pattern to use for testing in the Factor 2 Field.  When TESTB is
executed, the indicators in the Resulting Indicators Field (columns
54-59) are turned ON and OFF according to the results of the test.

You can enter an alphanumeric literal, a field, a table, or an array
element in the Factor 2 Field.  In all these cases, Factor 2 must be a
single character.  If you enter a field, table, or array, its ON bits are
compared with the Result field.  If you enter an alphanumeric literal,
you specify the bits to be tested.  Enter up to eight digits enclosed in
quotation marks.  Enter a digit for each bit position you want to test.
Zero (0) stands for the high-order bit and seven for the low-order bit.
You can enter the bit numbers in any order; if you do not enter a number
for a bit, it is not tested.  For example, "02" tests bits 0 and 2 to
determine whether they are turned ON. If the bit pattern for the
character in the Result Field is 10100000, the equal resulting indicator
is turned ON.

You must enter at least one indicator in the Resulting Indicators Field
and you may enter up to three.  You can enter the same indicator in two
of the fields, but not in all three.  If all of the bits in Factor 2 are
turned OFF, no resulting indicators are turned on.  If the bits specified
for Factor 2 are OFF in the Result Field, the resulting indicator in the
High Subfield (columns 54-55) is turned ON. If two or more bits do not
match in these fields, the resulting indicator in the Low Subfield
(columns 56-57) is turned ON. If all bits that are turned ON in the
Factor 2 Field are also turned ON in the Result Field, the indicator in
the Equal Subfield (columns 58-59) is turned ON.

Example 

Figure 8-45 shows how to use the TESTB operation.  The operation compares
the alphanumeric literal "0356" to the one-character field RESLT. The
literal "0356" stands for the bit pattern 10010110 and indicates that
bits 0, 3, 5, and 6 in the Result Field are to be tested.  If the Result
Field contains the bit pattern 01101001, indicator 01 is turned ON. If
the Result Field contains 11110000, indicator 02 is turned ON. If the
Result Field contains 10010110, indicator 03 is turned ON.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|            C                     TESTB"0356"    TESLT   1  010203               |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-45.  Using the TESTB Operation 

TESTN 

This compare and test operation (TEST Numeric) tests an alphanumeric
field for numeric characters.  You can use this operation before
arithmetic or editing operations to avoid unpredictable results or
program termination.  When TESTN is executed, the indicators in the
Resulting Indicators Field (columns 54-59) are turned ON and OFF
according to the results of the test.

If all characters in the Result Field are numeric or blank, the indicator
in the High Subfield (columns 54-55) is turned ON. In this case, each
character except the low-order character must contain a digit to be
numeric.  The low-order character is numeric if it contains A-R, or +0
(octal 173), or -0 (octal 175.)  If the Result Field contains numeric
characters and leading blanks, the indicator in the Low Subfield (columns
56-57) is turned ON. (Do not enter an indicator in this subfield when you
are testing a field one character long, because the field must contain a
character and a leading blank for the test to be valid.)  If the field
contains blanks only, the indicator in the Equal Subfield (columns 58-59)
is turned ON.

You can use the same indicator to test for more that one condition.  The
indicator is turned ON when any of the conditions are met.

TESTZ 

This compare and test operation (TEST Zone) tests the zone bits of the
high-order character of an alphanumeric field, and sets the indicators in
the Resulting Indicators Field (columns 54-59) accordingly.

Enter the field to test in the Result Field.  Enter an indicator in the
High Subfield (columns 54-55) to turn ON that indicator when the
character has a 12-zone (the characters &, +0, or A-I). Enter an
indicator in the Low Subfield (columns 56-57) to turn ON that indicator
when the character has an 11-zone (the characters -, -0, and J-R). Enter
an indicator in the Equal Subfield (columns 58-59) to turn ON that
indicator when the character has some other bit pattern.  Do not use the
Factors 1 and 2 Fields.

TIME 

This system operation returns the time of day (system) and, optionally
the current date.  TIME uses the system intrinsics CLOCK and optionally,
CALENDAR.

To use TIME, leave the Factor 1 and Factor 2 Fields blank.  Enter the
name of the numeric field where you want to save the time (and
optionally, the date) in the Result Field.  The length of the field that
you enter determines whether the date is also returned.  The field must
be either 6 or 12 digits long; 6 for returning the time and 12 for
returning the time and date.  Specify that the Result Field has zero
decimal positions.  The following lines show the time and date values
that are placed in the Result Field.

  This value is placed                                    When: 
  in the Result Field: 

hhmmss                             The Result Field length is 6.

                                   The time is based on a 24-hour clock where hh
                                   represents hours, mm represents minutes, and ss
                                   represents seconds.

hhmmssmmddyy                       The Result Field length is 12 and the Inverted
                                   Print Field (column 21) of the Header Specification
                                   is blank.

                                   The date is represented in Domestic Format where mm
                                   is the month, dd is the day, and yy is the year.

hhmmssddmmyy                       The Result Field length is 12 and the Inverted
                                   Print Field (column 21) of the Header Specification
                                   is I, J, or D.

                                   The date is represented in Foreign Format where mm
                                   is the month, dd is the day, and yy is the year.

Leave the Half Adjust and Resulting Indicators Fields blank.

When TIME is executed, the date is retrieved dynamically from the system.
It is not taken from the static UDATE field (which can be different from
system date).  For example, if a program begins shortly before midnight
on 12/31/88, UDATE is initialized to 123188 and remains unchanged for the
duration of the program.  If the program runs past midnight, the TIME
operation must be used to obtain 010189.

Example 

Figure 8-46 shows the two ways to use TIME. Line 1 returns the time in
the field TIMEA. Line 2 returns the time and date in the field TIMEB.
___________________________________________________________________________________
|                                                                                 |
|                1         2         3         4         5         6         7    |
|            678901234567890123456789012345678901234567890123456789012345678901234|
|              _______________________________________________________            |
|                                                                                 |
|     1     C                     TIME           TIMEA   60       TIME OF DAY     |
|            C                                                                    |
|     2     C                     TIME           TIMEB  120       TIME AND DATE   |
|                                                                                 |
|                                                                                 |
___________________________________________________________________________________

          Figure 8-46.  Using the TIME Operation 

TIME2 

This system operation extracts all or part of a formatted system date and
time string and stores it in a field in the program.  TIME2 uses the
DATELINE and CALENDAR intrinsics.

To use TIME2, leave the Factor 1 Field blank and, in the Factor 2 Field,
enter the position where extraction begins.  You can use a numeric
literal or field for Factor 2.  If Factor 2 is a numeric literal, it must
be an unsigned number from 1 to 40 (entered in columns 33-34).  If Factor
2 is a numeric field, it must be less than 5 digits and contain no
decimal positions.  Enter the name of the alphanumeric field where you
want to save the returned date and time in the Result Field.  The length
of the Result Field determines how many characters are extracted.  It can
contain a maximum of 40 characters (the sum of the Result and Field
Length Fields must not exceed 40).  Leave the Decimal Positions, Half
Adjust, and Resulting Indicators Fields blank.

The 40-character system date and time string has the following format
(the starting positions of sections of the string are also shown):
[REV BEG]

     day,  mon  dd,  year,  hh:mm  xM    JULIAN:nnn
      ^    ^    ^    ^      ^       ^            ^
      |    |    |    |      |       |            |
      1    6    10   14     20      26           38   (starting positions)

[REV END]

The day is the day of the week; mon is the month; dd is the day number;
year is the 4-digit year; hh is hours; mm is minutes; xM is AM or PM; and
nnn is the day of the year in Julian format.

Example 

Figure 8-46 shows several TIME2 operations.  Given the date 11/7/88 and
the time 9:25 AM, the extracted results are:

       1   MON, NOV 7,1988, 9:25 AM JULIAN:042

       2   MON, NOV 7,1988, 9:25 AM

       3   NOV 17, 1988

       4   1988

       5   9:25 AM

       6   042

Figure 8-46.  Using the TIME2 Operation 

UNLCK 

See the LOCK operation.

XFOOT 

This arithmetic operation sums all elements of a numeric array and places
the sum in the Result Field.  Factor 2 names the array to sum and it must
be numeric.  The Result Field can be a field or an array element.  If it
is an element of the array entered in Factor 2, the element's value
(before the XFOOT operation) is used during summing.  Do not use the
Factor 1 field.  You can half adjust the total in the Result Field.  When
you do this, rounding is done after all elements are added.

Z-ADD 

This arithmetic operation (Zero and ADD) replaces the Result Field by
Factor 2.  Factor 1 is not used.  High-order truncation occurs if the
Result Field length is less than the Factor 2 length.

Z-SUB 

This arithmetic operation (Zero and SUBtract) replaces the Result Field
by the negative representation (complement) of Factor 2.  High-order
truncation occurs if the Result Field length is less than the Factor 2
length.



MPE/iX 5.0 Documentation