pTAL Guidelines for TAL Programmers
Coding Guidelines
pTAL Guidelines for TAL Programmers—527256-002
2-36
Formal Value Parameters of Data Type STRING
Formal Value Parameters of Data Type STRING
Guideline: Do not declare formal value parameters of data type STRING.
In TAL, a procedure can declare a formal value parameter whose data type is STRING.
TAL passes each actual parameter of data type STRING in a 16-bit word; however, in
TAL, the calling procedure passes the STRING parameter in the right-hand side of the
16-bit word, whereas the called procedure references the parameter in the left-hand
side of the 16-bit word.
Your code might compensate for this discrepancy by:
•
Passing the actual value in a 16-bit word; for example:
INT i;
i := "s";
CALL callee (i);
•
Passing the actual value as a two-byte literal; for example:
CALL callee (" a");
•
Compensating in the called procedure; for example:
PROC callee(param);
STRING param;
BEGIN
IF param[1] ...
END;
In pTAL, the compiler reports a syntax error if you declare a formal value parameter of
type STRING; therefore, the declaration of parameter param in the preceding example
is not valid in pTAL.
You can change param to a reference parameter, provided that doing so does not
compromise the integrity of your program. If you change param to a reference
parameter and change its value within the callee procedure, the changes you make
in callee will be made to the variable that was passed to the caller. You might need to
declare a local variable and move the value of param into the local variable:
PROC callee(param_value);
STRING .param_value;
BEGIN
STRING param := param_value;
...
END;