• Aucun résultat trouvé

PROCEDURE (B,C) FIXED;

DECLARE X FIXED, Y ENTRY, Z LABEL;

A: PROCEDURE (B,C) FIXED;

I: EN'I'RYi Examples:

B: PROCEDURE;

C=A (X, Y) END B;

A: PROCEDURE (B,C) FIXED;

RE'I'URN (B*C + SIN (P»

END Ai

If procedure A is invoked as a function, as i t is in procedure B, then when control is returned to B, the expression (B*C + SIN (P» is evaluated, converted to fixed point, and the value assigned to C in procedure B.

The PUT Statement

Funct~ion:

The PUT statement has meaning only when there is a current file: if there is no current file, the ERROR condition is raised. The PUT statement then causes data to be fetched from variables as specified and to be moved to the record being con-structed for the current file (see

"Procedure-Directed Chapter 7) •

General format:

Transmission, II

PUT data-specification • • • I Gene:r-al rules:

in

1. The "data specifications" are dis-cussed in "Data Specifications," in Chapter 7. Only tho~e forms specified for output may be used: a CALL option may not be used.

2. As the data record is being formed, the action that occurs is as if a pointer moved across the record as demanded by the data specifications.

This pointer may be repositioned by use of the POSITION statement or the REPOSITION statement.

The character count of varying-length records depends upon the rig'htmost sweep of the pointer. The character count of fixed-length records is predetermined.

The READ Statement E'unct,ion:

']~he READ statement is normally used to transmit data from an external storage

medium to internal the STRING option statement causes the an internal storage storage areas.

storage. However, if is specified, the READ movement of data from area to other internal General format is shown in Figure 8.

Syntax rules:

1. The options may appear in any order.

2. At least one "data specification" must appear, but more than one is permissi-ble. The CALL option may appear in conjunction with other data specifi-cations.

3. When the STRING option is used, only the data specifications may be used;

the other options must not appear, nor may the CALL option.

4. Each "expression" is a scalar expres-sion.

General rules:

1. The FILE option specifies the name of the file from which the data is to be acquired.

The STRING option provides for the internal editing and moving of strings. It specifies the name of a string variable or the name of an element in a string array from which data is transmitted to the data list.

In the absence of a FILE or STRING option, the standard system input file is assumed.

2. The data specifications are discussed in "Data Specifications," in Chapter 7. Only those forms specified for input may be used. All modes of transmission may be arbitrarily speci-fied together. The transmissions associated with each data specifi-cation and edit procedure are per-formed in the order that the options appear.

r---,

[

FILE (file-name)]

READ {data-specification}

STRI NG (name)

[CROSS [(expression)] [HOLD] ] SEGMENT (expression)

[PRIN'I'] [KEY (expression)] [REGION (expression)]

[ZERO] :

Figure 8. General Format for the READ Statement

3.

4.

5.

Each READ statement normally processes one record; an error condition is normally produced if the data specifi-cation causes the record bounda1~ to be crossed. However, the CROSS option permits data acquisition to proceed through any number of records in order to satisfy the specified data require-ments. The number of records read may be limited by the integer value of the expression in the CROSS option. If no expression is specified, unlimited crossing is allowed. The margin qual-ifications for the data file, if spec-ified by a LAYOUT statement, remain valid while under control of the CROSS option. Record boundary crossing due to LIST, DATA, or SEGMENT does not previous operation ceased scanning.

If HOLD is not specified, the segment be encountered while transmit-ting data, transmission ends for that data specification.

The PRINT option specifies that data being read is, at the same time, 1::0 be written, in the same format, on the standard output file.

The KEY and REGION options may be used COUNT (file-name) built-in function may be used to determine this number under format-directed transmission for one record. The first 20 characters of the record are placed in the character-string variable ITEM.NAM.E, the next 5 are converted from converted to integer representation, and each item is assigned to the array character-string array AB. 1>.ssignment ceases when either the complete array is satisfied or the SEGMENT mark, the asterisk, is encountered (in the for-mer case, the input data stream is subsequently synChronized to the seg-ment mark) •

READ DATA;

This statement under data-directed transmission specifies that data is to be read under data-directed transmis-sion from the standard system input tape. It is assumed that the records to be read are composed of scalar

assignments gl.vl.ng the data items to be read and of these data items.

names of the the values

The REPOSITION Statement Function:

Duri.ng data transmission, the action that occurs is as if a pointer moved across the records being processed. If an error condition occurs during this activity, then, under the control of an ON statement, a REPOSITION statement may reset the poin'-ter to the start of the data item that caused the error condition.

General format:

REPOSITION;

Examples:

READX: PROCEDURE;

READ FILE (FILEX) CALL GETY;

END READX;

(X) (F (7 , 2) )

GETY: PROCEDURE;

ON CONVERSION (FILEX) REPOSITION;

GET (y) (X (1 7), F (7 , 2) ) ; RETURN;

END GE'1~Y;

The RES,]~ORE Sta.tement

~'unct:ion:

The RESTORE statement causes data pre-viously saved by name in auxiliary storage to be restored (see "The SAVE statement") •

1.

2.

3.

General format:

RESTORE (item, [, item] ••• ) [, (expression) ]

Synta.x rules:

Each "item" may be an array, majo~

structure name, or a scalar which is not part of an array or structure.

Each item must have appeared in a previously executed SAVE statement;

The "expression" is a scalar expres-sion.

General rules:

1. The RESTORE statement without an expression is equivalent to a series of simple RESTORE statements as fol-lows:

RESTORE (item1) RESTORE (item2)

The RESTORE statement with an expres-sion is equivalent to the following statements:

temp=expression

RESTORE (i tern 1) (temp) ; RESTORE (i tem2) (temp) ;

Each simple RESTORE statement causes the specified data to be iden-tified by the data name qualified by the integer value of the expression (if an expression is specified) con-verted to BINARY FIXED (s,O), where s is implementation defined. -2. Once an item has been restored,. i t may

not be restored again. If the same item has been saved repeatedly with no qualifying expression, the action of restoring the data causes the top item of the stacked information to be deleted. Therefore, the stacked information is treated in "first-in last-out" manner.

3. An item may be saved in one external procedure and restored in another if the data name is declared EXTERNAL.

4. One SAVE statement may be used to save more than one scalar, array, or struc-ture; however, these items may be restqred separately.

5. The extents of the data restored must be the same as the data saved.

Examples:

1 • RESTORE (A, B , C) ;

2.

Assume that the scalar data items A, B, and C were previously saved by using the SAVE statement. The RESTORE statement then causes A, B, and C to be made available for computation.

SAVERM: PROCEDURE

DECLARE TABLE (10) , 1 2 RED, 3 CRIMSON, 3 BLUE, 3 NAVY, 3 YELLOW;

RAINBOW, PINK, 2 'I'EAL, 2

SAVE (TABLE, RAINBOW);

RESTORE (TA.lJLE)

RESTORE (RAINBO~

END SAVERM;

Since TABLE is an array and RAINBOW is a structure, the SAVE statement causes all 10 data items in TABLE to be saved and the elementary items (CRIMSON, PINK, NAVY, TEAL, and

YELLO~ of the structure to be saved.

The first RESTORE statement causes the entire array to be restored; the second RESTORE statement causes the elementary items of the structure to be restored.

:rhe RETURN Statement Function:

The RETURN statement terminates ex'ecu-tion of the procedure that contains the RETURN statement and returns control to the invoking procedure. It may also return a value.

General format:

Option 1.

RETURN;

Option 2.

RETURN (expression) General rules:

1. Only the RETURN statement in Option 1 can be used to terminate procedures not invoked as function procedures;

control is returned to the point logi-cally following the invocation.

Option 1 represents the only form of the RETURN statement that may be used to terminate a procedure imToked with the task option. If the task option involved an EVENT option (see

"The CALL Statement,n in this Chapter), then the execution of the RETURN statement will cause the com-pletion status of the associated event name to be set to 'l'B.

2. The RETURN statement in Option 2 is used to terminate a procedure invoked as a function procedure. Control is returned to the pOint of invocation, and the value returned to the function reference is the value of the expres-sion specified.

If the entry point at which the procedure is invoked specifies data attributes, the value of the expres-sion is converted to the implicit or explicit data attributes specified at the entry point, before i t is returned.

3. If control reaches an END statement corresponding to the end of a proce-dure, this END statement is treated as a RETURN statement (of the Option 1 form) for the procedure.

Example: