pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-25
Scanning Data in P-Relative Arrays
Scanning Data in P-Relative Arrays
TAL
The address type of pointers in an SCAN or RSCAN statement that scans a P-relative
array must be CBADDR or CWADDR. When the SCAN statement in Example 15-37 on
page 15-25 completes, t_start points to the first character in the third message, and
t_end points immediately after the last character in the third message.
pTAL
The data type of variables that contain the addresses of data in P-relative arrays must
be CBADDR or CWADDR. In Example 15-37 on page 15-25, the object data type of
t_start and t_end is STRING and their address types, therefore, are BADDR. In
Example 15-38 on page 15-26, t_start and t_end are type CBADDR.
BADDR end_addr;
...
s.stopper := 0;
SCAN s.buffer UNTIL char -> end_addr;
IF end_addr = @s.stopper THEN
BEGIN
! Target character was not found
...
END;
Example 15-37. Scanning Data in P-Relative Arrays (TAL)
STRING s = 'P' :=
[ 1, "msg1.",
2, "msg2.",
3, "msg3.",
0 ]; ! STRING P-relative array s
STRING .t_start, ! Start address of msg
.t_end; ! End address of msg
INT c := 3, ! Value to scan for in s
z := "."; ! Value to stop the scan
SCAN s UNTIL c -> @t_start; ! Scan s for c and store c's
! address in t_start
@t_start := @t_start '+' 1; ! Skip c
SCAN s[@t_start '-' @s] ! Find end of message
UNTIL z -> @t_end;
Example 15-36. pTAL Structure With FIELDALIGN(SHARED2) (page 2 of 2)