Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Creating and executing EDT procedures

&pagelevel(4)&pagelevel

When creating and executing EDT procedures it is necessary to observe the following rules.

Reading statements and data lines

When executing an EDT procedure, EDT reads statements and data lines in L mode. If the EDT procedure is started in F mode, EDT switches to L mode, executes the procedure and then switches back to F mode.

The distinction between statements and data lines is therefore governed by the same rules as for input in L mode (see section “L mode”). In particular, lines with two consecutive (possibly separated only by blanks) EDT statement symbols or user statement symbols are interpreted as data lines. This makes it possible to construct other procedures dynamically within procedures and run these immediately (see example below).

Permitted statements

All the statements that are permitted in L mode may be used in EDT statements with the exception of the @DIALOG, @DROP and @INPUT statements (see section “L mode”).
In @DO procedures, the statements @GOTO, @DO (Format 2) and @PARAMS are also permitted. In @INPUT procedures, the @IF ... GOTO statement is tacitly ignored if the condition is not fulfilled and is rejected with the error message EDT4942 if the condition is fulfilled.

Current and active work file, special work files

In L mode, the current work file is called with the @PROC or @SETF statement and in F mode with the @SETF statement or by entering the corresponding work window in the statement line. When EDT procedures are executed, the read statements and records always apply to the current work file. The current work file must therefore not be specified in a @DO statement.
The attempt is rejected with the message EDT4906.

Active work files are those work files which contain a @DO procedure which is currently being executed. If @DO procedures are nested then multiple work files can be active (up to 22), i.e. those that have been activated by a @DO and have not yet been exited with a @RETURN.

When @DO procedures are nested, an active work file may also be specified in @DO statements.

Recursive calls are therefore possible but again only to a maximum nesting depth of 23. An active work file must not be made into the current work file. A @PROC or @SETF statement for an active work file is therefore rejected with the message EDT4959.

@DO procedures can be stored and run in every work file with the exception of work file 0, i.e. in work files 1 to 22.
A @DO 0 is rejected with the message EDT3209.
Since many EDT statements write their output to work file 9 by default, it is advisable not to use this work file for @DO procedures.

EDT procedures and character sets

When an EDT procedure is executed, statements and records are read in the character set of the current EDT procedure.
In the case of @INPUT procedures, this is the character set of the cataloged file or library element; in the case of @DO procedures, it is the character set of that active work file which is being read. The read data records and the literals or text-type expressions may have to be converted if they refer to objects (e.g. the current work file or a string variable) to which another character set is assigned. For the precise rules, see section “Character sets”.

Example: Creating and calling a @DO procedure in F mode

This switches to work file 22. The procedure is created in this work file.

SNAPSHOT-ID-489389.png

The statements are created in work file 22. After this, processing returns to work file 0.

The procedure in work file 0 is called with @DO from work file 0.

The result of running the procedure can be seen in work file 0.

Example: Calling a procedure in L mode as a @DO procedure

1.     @PROC 1 -------------------------------------------------------- (01)
1.     @ @CREATE 1: 'THIS IS AN EXAMPLE'
2.     @ @CREATE 2: 'OF A PROCEDURE IN L MODE'
3.     @ @COPY 1 TO 3-------------------------------------------------- (02)
4.     @ @DELETE 1:1-8
5.     @ @PRINT
6.     @END ----------------------------------------------------------- (03)
1.     @DO 1 ---------------------------------------------------------- (04)
1.0000 AN EXAMPLE
2.0000 OF A PROCEDURE IN L MODE
3.0000 THIS IS AN EXAMPLE
4.

(01)

Processing switches to work file 1.

(02)

EDT statements are written to work file 1 (@DO procedure). Here, the L mode input mechanism is used to insert lines with two EDT statement symbols as data lines in the work file and truncate these before the second statement symbol (see section “L mode”).

(03)

Processing returns to work file 0.

(04)

Call of the @DO procedure. The statements in the work file are executed.