pTAL Conversion Guide

Expressions
pTAL Conversion Guide527302-002
13-8
Using Indexing
Using Indexing
TAL
You can index any variable except an entire structure, which you can index only if it is
a structure array.
pTAL
You cannot index simple variables or value parameters because they do not point to
arrays. You can, however, index the following simple variables:
Variables in any global data block, including the unnamed global data block
Equivalenced variables and reference variables
Direct SG variables
Fields of a structure
Example 13-6. Indexing in TAL and pTAL (page1of2)
INT i1; ! Global INT simple variable
INT .i2; ! Global pointer
INT .EXT i3; ! Global extended pointer
INT t; ! Simple temporary location
PROC p(j, k, l);
INT j; ! Value parameter
INT .k; ! Reference parameter
INT m; ! Parameter that is referenced in an
! equivalenced declaration
BEGIN
INT i4 = m; ! Equate that references a parameter
INT i5; ! Local simple variable
INT .i6; ! Local pointer
INT i7; ! i7 and i8 both participate in an
INT i8 = i7; ! equivalence group
STRUCT s1; ! Local structure
BEGIN
INT a;
INT .b;
STRUCT c;
BEGIN
INT d;
END;
END;
t := i1 [1]; ! OK: i1 is global
t := i2 [1]; ! OK: i2 is a pointer
t := i3 [1]; ! OK: i3 is a global extended pointer
t := i4 [1]; ! OK: i4 is in an equivalenced variable
t := i5 [1]; ! ERROR: cannot index a simple local variable
t := i6 [1]; ! OK: i6 is a pointer