When @DO procedures are created in EDT, @PARAMS can be used to define formal parameters to which current values (current parameters) are assigned when the procedure is called with @DO.
The @PARAMS statement must be the first statement in a @DO procedure and may only occur once in the procedure. Both positional and keyword parameters are permitted. All the positional parameters must be defined before the keyword parameters.
A formal parameter starts with the character &
. This is followed by a letter which in turn is followed by up to 6 letters or digits.
When the procedure is called, the parameters in the @DO statement are specified as the current parameters. It is also possible to set keyword parameters to a default value within the @PARAMS statement.
The default value is used if the corresponding keyword parameter is not specified in the @DO statement. When the procedure is called, the formal parameters in the procedure are replaced by the values of the current parameters or the default values.
The processing of these parameters should be considered as a two-stage process. First of all in the called procedure, the text of the formal parameters is replaced by the current parameters and the modified lines are then processed. Here, it may be necessary to take account of the presence of a number of different character sets, i.e. the character set in the statement (for the current parameters), the character set used in the work file that is to be run as a procedure and the character set of the current work file to which the statements in the procedure are applied or in which the records are inserted.
In the first stage of text substitution, it is therefore necessary to convert the character set of the statement into the character set of the executing procedure.
This applies both to the names of the specified current parameters and the names of the formal keyword parameters. If the current parameters contain a substitute representation for Unicode characters (see section “Substitute character representation in Unicode”), then they are not converted into the corresponding Unicode characters at the time of text substitution even if the current parameters are quoted.
In the second stage of processing (execution), both lines and literals in statements must be converted from the procedure's character set into the character set of the current work file. This operation includes the interpretation of a substitute representation for Unicode characters if substitute representation in a literal has been used.
It is not possible to pass through the current parameters unmodified since text substitution can take place at any position in a line in the executing procedure (in literals, in other operands or even in the statement name itself).
If in a Unicode environment, a procedure file is used which is present in a 7-bit or 8-bit character set, undesired character substitutions may therefore occur during the recoding of a parameter entered in Unicode into the character set used in the procedure file. This can only be prevented by using the substitute representation for Unicode characters (see above). For the precise rules governing recoding, see section “Character sets”.
Note
If EDT procedures with parameters are also to be used in BS2000 system procedures which also contain parameters, it is advisable to set the BS2000 parameter symbol to a value other than &
(/SET-PROC-OPT DATA-ESCAPE-CHAR=...
) in order to avoid conflicts.
Example for the use of parameters in an EDT procedure
In the following example, a file is read into work file 0. The records which contain the search term are copied into work file 5, prepared accordingly and output on the screen.
1. @PROC 4 1. @DELETE 1. @ @PARAMS &FILE,&SEARCH --------------------------------------- (01) 2. @ @DELETE 3. @ @READ '&FILE' 4. @ @ON & FIND PATTERN '&SEARCH' COPY TO (5) 5. @ @PROC 5 6. @ @CREATE 0.01: '~' * 50 7. @ @CREATE 0.02: 'MENU ','&SEARCH' 8. @ @CREATE 0.03: '~' * 50 9. @ @RENUMBER 10. @ @CREATE $+1: '~' * 50 11. @ @PRINT 12. @ @END 13. @END 1. @DO 4 (MENU,CW 49) ------------------------------------------- (02) 1.0000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.0000 MENU CW 49 3.0000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4.0000 CW 49 - 05.12. CORN FRITTERS, CHOCOLATE MOUSSE 5.0000 CW 49 - 06.12. BEEFBURGER, BOILED POTATOES, YOGHURT 6.0000 CW 49 - 07.12. CUMBERLAND SAUSAGE, FRENCH FRIES, FRUIT SALAD 7.0000 CW 49 - 08.12. PENNE IN GARLIC AND MUSHROOM, TRIFLE 8.0000 CW 49 - 09.12. COD IN BATTER, SAUTE POTATOES, APPLE FLAN 9.0000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10. @DO 4 (MENU,SAUSAGE) --------------------------------- (02) 1.0000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2.0000 MENU SAUSAGE 3.0000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4.0000 CW 45 - 10.11. SAUSAGE AND EGG, FRENCH FRIES, CUSTARD PUDDING 5.0000 CW 49 - 07.12. CUMBERLAND SAUSAGE, FRENCH FRIES, FRUIT SALAD 6.0000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(01) | Define the symbolic parameters (two positional parameters). |
(02) | Call the procedure with the associated current parameters. The formal parameters in the @READ, @ON statement are replaced by the current values on each @DO call. |