pTAL Conversion Guide

Equivalenced Variables
pTAL Conversion Guide527302-002
12-18
pTAL
pTAL
pTAL requires .SG (or .SGX) indirection notation for pointers to data in system globals
and for fields within a structure in system globals; therefore, it accepts only the second
pair of declarations.
Using Equivalenced Variables
You can use an equivalenced variable in an expression anywhere an operand is valid.
In pTAL, you can index a variable that participates in an equivalenced declaration—
either as the equivalenced variable or as the previous variable—even if none of the
variables in the equivalenced group specify array bounds.
Example 12-16. .SG Notation in pTAL
STRUCT .SG s = 'SG' + 0;
BEGIN
INT .SG i;
INT(32) .SG j;
STRUCT k;
BEGIN
INT .SG m;
END;
INT n;
END;
Example 12-17. Equivalenced Variables
INT a; ! Simple variable, cannot be indexed
INT b; ! "Previous variable" for next declaration
INT c = b; ! b and c can be indexed
INT d = c; ! c and d can be indexed
c[2] := b[1]; ! OK: b and c appear in an equivalenced
! declaration
d[2] := c[1]; ! OK: c and d appear in an equivalenced
! declaration
d[2] := a; ! OK: d appears in an equivalenced declaration
a[1] := d; ! ERROR: a cannot be indexed