pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-24
Extended Pointers
Extended Pointers
TAL
The scan variable in an SCAN or RSCAN statement must refer to data in the user data
segment.
pTAL
The scan variable can refer to data declared with the .EXT indirection symbol. In this
case, the address type of the next-address variable must be EXTADDR.
Scanning Across Variable Boundaries
SCAN and RSCAN statements that access data contained within single named
variables or arrays have the same characteristics in TAL and pTAL as long as the scan
encounters either the target character specified in the SCAN or RSCAN statement or a
0 byte before it reaches the end of the named variable or array.
SCAN and RSCAN statements that depend on accessing data that precedes or follows
the variable named in the SCAN and RSCAN statement do not work in pTAL. Although
the native compiler allocates memory for global variables in the order in which you
declare the global variables and allocates memory for structure fields in the order in
which you declare the fields, the native compiler might add filler between variables or
fields to optimize data alignment on the native architecture, which changes the result of
an SCAN or RSCAN statement in unpredictable ways. The same is true if the buffer
scanned in an SCAN or RSCAN statement is a reference parameter.
A pTAL structure that specifies FIELDALIGN(SHARED2) has the same layout as a TAL
structure.
Example 15-35. Extended Pointers in pTAL SCAN and RSCAN Statements (pTAL)
STRING .EXT s;
STRING .EXT t;
EXTADDR u;
SCAN s until " " -> @t; ! OK
SCAN s until " " -> u; ! OK
Example 15-36. pTAL Structure With FIELDALIGN(SHARED2) (page 1 of 2)
STRUCT s FIELDALIGN(SHARED2);
BEGIN
STRING buffer;
STRING stopper;
END;