pTAL Reference Manual (H06.03+)
Statements
HP pTAL Reference Manual—523746-005
12-44
P-Relative Arrays
In Example 12-50 on page 12-44, the data type of t_start and of t_end is
CBADDR. The object data type of s is STRING. Its address type is CBADDR, not
BADDR; therefore, you can subtract @s from t_start because the data types of
both are CBADDR.
Example 12-49. Scanning Data in a P-Relative Array
STRING s = 'P' := ! STRING P-relative array s
[ 1, "msg1.",
2, "msg2.",
3, "msg3.",
0 ];
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]
UNTIL z -> @t_end; ! Find end of message
Example 12-50. Scanning Data in a P-Relative Array
STRING s = 'P' := [ ! STRING P-relative array s
1, "msg1.",
2, "msg2.",
3, "msg3.",
0 ];
CBADDR t_start, ! Start address of msg
t_end; ! End address of msg
INT c := 3, ! Value to scan for in s
z := -1; ! 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 character in c
SCAN s[t_start '-' @s]
UNTIL z -> t_end; ! Find end of message










