• Aucun résultat trouvé

DECLARE X FIXED, Y ENTRY, Z LABEL;

1. IOPR: PROCEDURE;

Examples:

1. IOPR: PROCEDURE;

R 1: READ FILE (FILEX) (A, B) (2F (7,3) ) ;

ON CONVERSION (FILEX) CONVQ

=

9999;

R2: READ FILE (FILEX) (X)

(A (6) ) ;

END IOPR;

Assume that program execution begins with procedure rOPR. At the beginning of execution, all conditions are enabled.

If an illeqal from FILEX during statement R1, the action occurs.

character is read the execution of standard system

~['he ON statement. specif ies that the execution of the statement COWQ

=

2.

9999 is to occur in the event that a conversion error causes an interrupt subsequent to execution of the ON statement. Thus, if a conversion error occurs during the transmission of X in statement R2, the normal sequence of control is interrupted, and the statement CONVQ 9999 is executed.

ZCHK: PROCEDURE;

S1 : ON OVERFLOW OVSWCH 1 ;

CALL Q;

Q: PROCEDURE;

S2: ON OVERFLOW OVSWCH 2;

S3: ON OVERFLOW SYSTEM;

END Q;

END ZCHK;

Assume that program execution begins with procedure ZCHK.

If an overflow occurs prior to execution of the S1 : ON statement, an interrupt with standard system action occurs. If an overflow occurs subse-quent to execution of the S1 ON statement, an interrupt occurs, and the statement OVSWCH = 1 is executed.

When procedure Q is invoked, the S1 ON statement remains in effect until the S2 : ON statement is executed. At this point, the effect of the 51 : ON is temporarily suspended, and the 52 : ON goes into effect.

If an overflow occurs between the 52 : ON and the S3 : ON, an interrupt occurs, and the statement OV5WCH 2 is executed.

When the 53 : ON is executed, i t completely replaces the 52: ON (the S1 ON is still stacked). If an overflow occurs after the 53: ON is executed and before the end of proce-dure Q, i t causes the standard system action to take place.

3.

After control is returned from Q to ZCHR, the S3: ON is completely replaced by the S1: ON, whose effect is restored. Any overflows occurring from this point to the end of proce-dure ZCHK cause the statement OVSWCH

=

1 in S1: ON to be executed.

SBCHK: PROCEDUREi

DECLA.~E A (9) B1: • • • A(I} ••• i

ON SUBSCRIPTRANGE BEGIN;

IF 1>9 THEN GO TO BIGER ELSE GO TO

LITLERi

iHGER:

LITLER: ••• i

END;

(SUBSCRIPTRANGE): B2: ••• A (I) ••• , B3: ••• ;

END SBCHK;

Assume that procedure SBCHK is only procedure in the program.

the At the beginning of execution, any occurrence of the condition SUBSCRIP-TRANGE will not give an interrupt; i t is not enabled, since the condition name does not appear in a prefix in the PROCEDURE statement. However, the occurrence of any other ON condition, except SIZE and CHECK (identifier), will give an interrupt. If in state-ment B1, the value of I is greater

than 9 or less than 1, no interrupt action is taken.

When the ON statement for the con-dition SUBSCRIPTRANGE is executed, any interrupt that results from a subse-quent occurrence of the SUBSCRIPTRANGE condition will result in the action specified by the begin block in the ON statement.

The prefix for statement B2 speci-fies that the condition SUBSCRIPTRANGE is enabled and should cause an inter-rupt if i t occurs during the execution of statement B2. In this case, the begin block in the ON statement is executed.

In the execution of B3 and subse-quent statements, the occurrence of a subscript that is not within the spec-ified range does not cause an inter-rupt action to occur.

For further examples, see "Interrupt Operations" in Chapter 6.

The OPEN Statement Function:

The OPEN statement acquires and prepares files for subsequent transmission.

General Format is shown in Figure 5.

r---.---,

, I

I

I {filename

~ption]

••• } ,I

OPEN

I (filename [option] ••• [,filename [option] ••• ] ••• ) [option] ••• I

I [, filename [option] • • • ] I

I , filename [option] ••• [, fi lename [option] ••• ] ••• ) [option] ••• • •• i I

I I

I I

l _______________________________________________________________________________ J

Figure 5. General Format for the OPEN Statement

r---·---,

I I

I [~~~i!~TJ

[TITLE (expression)] [ACTIVITY (expression) ][ident-option] [ENVIRONMENT

I

I INOUT (option-list) ] I

I I

I I

l _______ . _____________________________________________________________________________ J

Figure 6. Format of "option" Allowed in the OPEN Statement

Syntax rules:

1. The options may appear in any order.

2. The "file name" may be described in a DECLARE statement with the file attri-butes discussed in Chapter 4.

3. Opt:ions that are common to two or more file names may be factored in the same way that attributes in a DECLARE staltement may be factored (see

"Factoring of Attributes" in Chapter 4). Only one level of factoring is permitted.

General rules:

1. The OPEN statement causes certain act:ions to be performed upon the file, whose name is one of the file names of the OPEN statement. These actions are specified by the options.

If, however, a file is not opened by an OPEN statement, the file is opEmed during the first READ or WRITE statement that refers to it.

If an OPEN statement is encountered for a file already opened, the state-ment is ignored.

2. The following options may be given to a file in the OPEN statement:

One of these options may be given to specify the direction of data transmission that is permit-ted for the file. INOUT may be given for both direct and sequen-tial access files, stating that both INPUT and OUTPUT are permit-ted.

Either the OPEN statement or the file declaration must specify the direction of data transmis-sion. References to the file in PAGE and LAYOUT statements before INPUT or OUTPUT is established, forces no assumptions. References to the file in GROUP, SPACE, SKIP, or SEGMENT statements before INPUT

or OUTPUT is established, forces the default assumption INPUT.

It should be noted that INPUT files may not be written upon and OUTPUT files may not be read.

b. [TITLE (expression)]

A file name may be associated with more than one set of data.

The choice of the desired set may be delayed until the OPEN state-ment is executed. At this point, the "expression" in the TITLE option is evaluated, converted to a character string, and used to identify the data set. The origi-nal file name is remembered, such that TITLE does not permanently override it. If the TITLE option is omitted, the file name is taken as the data set name. The TITLE option can be used to let the file name refer to more than one actual file.

c. [ACTIVITY (expression)]

The ACTIVITY option causes the

"expression" to be evaluated and converted to an integer that indi-cates the relative activity of the file. This relative activity is represented in units defined indi-vidually for each implementation 6f the language.

d. The format of the ident option is as follows:

(

data-list format list

I

IDENT

CALL entry-name [(argument [, argument]] ••• )

The ident option in an OPEN statement for an output file spe-cifies that a label is to be placed on the external medium.

For an input file, IDENT provides information for label checking.

The ident option specifying a data list and format list yields a character string that is compared

r---,

, I

I PAGE [FILE (file-name [,file-name] ••• )] I

I [NUMBER [(expression)]] [HEAD (expression)] I

I [FOOT (expression)] [SIZE (expression)] I

I [SPACE (expression)] I

I { (expression- 2) } ] I

I [AT (expression-1) I

I CALL entry-name (argument [, argument] •• ,,) ; I

l ____________________________________________________________________________ J

Figure 7. General Format for the PAGE Statement

with the file label for an input file or is written as the file label for an output file. For an INOUT file, INPUT is assumed. The data list and format list are described in Chapter 7.

The ident option specifying an entry name and argument list caus-es the specified file to become the current file and the designat-ed procdesignat-edure to be invoked for reading or writing the file label through GET or PUT. The form of file labels is implementation defined.

If the ident option is not specified, no special label opera-tions are performed.

e. The ENVIRONMENT option specifies various characteristics of the FILE being opened. See "The E"f:-,WI-RONMENT Attribute," in Chapter 4.

Examples: