• Keine Ergebnisse gefunden

FILE NAME-X,LABEL-FILEIN

Im Dokument IBM System/32 (Seite 60-69)

OC L Statement Descriptions

II- FILE NAME-X,LABEL-FILEIN

Substitutes the value of the nth positional parameter; or, if the nth parameter is not defined, temporarily assigns a default value to the parameter, and then substitues that value. This expressio.n format is the same as ?n'default'? except T means temporary and 'default' specifies the temporary default value. A temporary default value is used only for the current substitution expression. For subsequent references to the nth parameter within the procedure, the parameter is undefined. For example, a procedure member contains the following statement:

II

FILE NAME-?2TWEEKLY,?

If the second parameter was not defined, the following statement is penerated:

II

FILE NAME-WEEKLY

Introduction to Procedures 45

Page of GC21-7593-3 Issued 22 November 1978 By TNL: GN21-7993

. Substitution Format

?nR'msg-id'?

?nR?

Meaning

Substitutes the value of the nth positional parameter; or, if the nth parameter is not defined, displayes a message from the USERl message member and waits for the operator to enter from the

key-!board the value to be substituted. Subsequent references to the. nth parameter within the procedure member use the value entered by the operator. R indicates that an operator's reply is required if the parameter is not defined. Msg-id identifies the MID of the message to be displayed if the nth parameter is not defined. For example, a procedure member contains the following statement:

II FILE NAME-?2R'6666'?

If the second parameter is not defined, the following message (message 6666 from the USERl message member) is displayed:

ENTER NAME OF THE REQUIRED INPUT FILE

The operator then enters the word PAYROLL from the keyboard, and the following statement is generated:

II FILE NAME-PAYROLL

Subsequent references to the second parameter use PAYROLL.

Substitues the value of the nth positional parameter; or, if the nth parameter is not defined, displayes a system message (ENTER MISSING PARAMETER) and waits for the operator to enter the value to be substituted. Subsequent references to the nth parameter within the procedure member use the value entered by the operator.

R indicates that an operator's reply is required if the parameter is not defined. For example, a procedure member contains the following statement:

PAYROLL WEEKLY,?1R?

If the first parameter is not defined, ENTER MISSING PARAMETER is displayed. The operator then enters the word SALARY from the keyboard, and the following statement is generated:

PAYROLLWEEKLY~ALARY

Note: Within the procedure member namedPAYROLL, references to the second positional parameter use the word SALARY.

Substitution Format

?R?

Meaning

Page of GC21-7593-3 Issued 22 November 1978 By TNL: GN21-7993 "

Displays a system message (ENTER REQUIRED PARAMETER),"

and waits for the operator to enter the value to be substituted from the keyboard. R indicates that an operator reply is required. For example, a procedure member contains the following statement:

II FILE NAME-?R?

When the statement is being generated, ENTER REQUIRED PARAMETER is displayed. The operator then enters the word INFILE, and the following statement is generated:

II F1LE NAME-INFILE

Introduction to Procedures 48.1

This page intentionally left blank

Substitution

Format Meaning

?R? Displays a system message (ENTER REQUIRED PARAMETER), and waits for the operator to enter the value to be substituted from the keyboard. R indicates that an operator reply is required. For example, a procedure member contains the following statement:

II FILE NAME-?R?

When the statement is being generated, ENTER REQUI RED PARAMETER is displayed. The operator then enters the word

INFILE, and the following statement is generated:

II FILE NAME-INFILE

Conditional Expressions: I F and ELSE

Conditional expressions are used among DCl statements to modify procedures. There are two types of conditional expressions: I F expressions and ELSE expressions.

IF Expression

The I F expression can only be used in a procedure (can be anywhere in the procedure).

The I F expression tests to find out whether a condition is as specified (true or false);

if it is as specified, the statement parameter is executed; if not, the SCP goes to the next statement in the procedure.

There are three formats of the I F expression:

I I I F Condition-parameter Statement-parameter II I FT Condition-parameter Statement-parameter II IFF Condition-parameter Statement-parameter

I F or I FT means that if the condition is true, the statement is to be executed. IFF means that if the condition is false, the statement is to be executed.

Introduction to Procedures 47

Condition Parameter: There are two types of condition parameters: existence testing and comparison.

The existence testing parameter is a keyword parameter. The keywords and mean-ings are:

Keyword BLOCKS-value

Meaning

Is the available disk file space equal to or greater than the value specified?

DATAll-'name,date' Is there a file on the diskette with the name and creation or DATA11-name date (optional) as specified?

DATAF l-'name,date' Is there a file on the disk with the name and creation date or DATAF1-name (optional) as specified?

SOU RCE-name

(SWITCH2 through SWITCH8 can also be tested)

The comparison parameter format and meaning is:

Format Meaning

parameter 1!parameter2 Is parameterl equal to parameter2? (Each param-eter has a maximum length of eight characters.) Statement Parameter: The statement parameter of the I F expression can be an OCl

state-ment, (except the comment statement or end-of-data statement) a utility control statement, another IF statement, or a part of an OCl or utility control statement (continuation). Drop the initial!! of OCl and utility control statements used as statement parameters.

Also allowed in the statement parameter of the I F expression are the keywords CANCEL and RETURN. The meaning of these two keywords are:

CANCEL Cancel the job and return to the keyboard for the next OCl

RETURN Encountered in a first level procedure causes an immediate return to the keyboard for the next Oel statement. Encountered in a nested procedure causes an immediate return to the calling procedure for the next Oel statement.

The following example shows two levels of procedures, PAYROll (first level) and TAXES (second level). The TAXES procedure represents a nested procedure that contains the keyword RETURN in a conditional expression.

In this example, the keyboard entry is PAYROLL. PAYROll contains an optional parameter All TAX which is not specified so that the conditional expression is executed and the keyword RETURN is encountered. RETURN encountered in a nested procedure causes a return to the calling procedure (PAYROll). The remain-ing Oel statements in the TAXES procedure are not executed. The example:

Keyboard Entry

PAYROll (first level)

TAXES (second level) PAYROll---' II .. .

II .. .

TAXES ?1?'---1 II II

r - - - -

II IFF ?1?/ALlTAX RETURN II

"---- II II

- - - I I

Introduction to Procedures 49

If the ALL TAX parameter was specified in the keyboard entry, the RETURN key-word in the conditional expression would not be encountered, all OCL statements in the TAXES procedure would be executed, Clnd then processing returns to the PAYROLL procedure. For example:

Keyboard Entry

PAYROLL (first level)

TAXES (second level) PAYROLL [ALLTAX]-II .. .

II .. .

TAXES ... - - ·

II .. . II .. .

II

IFF ?1?/ALLTAX RETURN

II ...

II ... ... · - -.... 11 .. ,

-""',.,...-11 ...

Examples of the IF Expression: Following are some examples of the I F expression.

• Existence testing

II IFF DATAF1-?1? CREATEF1

This expression checks to see if the file label substituted for parameter 1 is on the disk. If it is n6t, the· condition is satisfied and the CREATEF1 procedure is evoked.

If the file is on the disk, the condition is,'not satis{ied and the next statement or expression in the procedure is read; CREATEF1 is not executed.

• Comparison

1/ IF ?1?/PAYROLl PAYROLL

This expr~ssion says that if the first parameteron the statement that evokes the procedure is PAYROLL, then evoke the procedure named PAYROLL; otherwise, go to the next statement or expression in the procedure. An expression equiva-lent to the preceding comparison example is:

II IF PAYROLL/?1? PAYROLL

• There can be more than one IF expression on a line. Aline is a maximum of 120 characters.

II IF PROC-PAYROlL1 IF SWrTCH3-1 PAYROLL

This expression says that if the procedure member PAYROLL 1 is in the pro-cedure library, and if UPSI (user program status indicator) switch 3 is on (1), then the procedure PAYROLL is evoked. If the procedure PAYROLl1 is not in the procedure library, or if the UPSI. switch is not on, the expression is ignored and the procedure PAYROLL is not evoked.

ELSE Expression

The ELSE expression requires the IF expression and the following restrictions apply:

• The ELSE expression must immediately follow the I F expression. The ELSE expression is ignored if it does not immediately follow an I F expression.

• Comments cannot be entered between the IF expression and the ELSE expres-sion. The ELSE expression is ignored if comments are entered between the IF expression and the ELSE expression.

For example:

The example tests whether the first parameter in the statement that evoked the pro-cedure is a null entry. A null entry is an entry that contains no value. In the statement

NAME PARMl "PARM3

the second parameter is a null entry.

Introduction to Procedures 51

The I F and ELSE statements in the preceding sample say: if the first parameter in the statement that evoked the procedure is a null entry, RETURN to the previous procedure if this is a nested procedure or to the keyboard if this procedure is not nested; if the first parameter in the statement is not a null entry, evoke the DELETE procedure to delete the file specified by the first parameter.

The ELSE expression can be used with all forms of the I F expression (I F, I FT, and IFF).

There can be only one ELSE expression per line and it must be the first expression in that line. An I F expression can follow an ELSE expression in a conditional statement. For example:

II iIF ?1 71 PA YR OL",

1/ El SE DE .LE rrE ?11

/1 IF ?2. 1/ RE rru RN

Im Dokument IBM System/32 (Seite 60-69)