pTAL Reference Manual (H06.08+)

Statements
HP pTAL Reference Manual523746-006
12-42
Determining What Stopped a Scan
Topics:
Determining What Stopped a Scan on page 12-42
Extended Pointers on page 12-42
Crossing Variable Boundaries on page 12-43
P-Relative Arrays on page 12-43
Determining What Stopped a Scan
To determine what stopped a scan, test $CARRY in an IF statement immediately after
the SCAN or RSCAN statement.
If $CARRY is true after a SCAN UNTIL, the test character did not occur. If $CARRY is
true after SCAN WHILE, a character other than the test character did not occur.
To determine the number of multibyte elements processed, divide (next-addr '-' byte
address of identifier ) by the number of bytes per element using unsigned
arithmetic.
For more information about $CARRY, see Section 13, Hardware Indicators
.
Extended Pointers
Example 12-45. SCAN UNTIL Statement
INT .words[-1:3] := [0,"Doe, J",0];
STRING .byte_ptr := @words[0] '<<' 1; ! Initialize with byte
! address of words[0]
SCAN byte_ptr[0] UNTIL ","; ! Scan bytes in words
Example 12-46. Determining What Stopped a Scan
IF $CARRY THEN ... ; ! If test character not found
IF NOT $CARRY THEN ... ; ! If test character found
Example 12-47. Extended Pointers in SCAN and RSCAN Statements
STRING .EXT s;
STRING .EXT t;
EXTADDR u;
SCAN s until " " -> @t; ! OK
SCAN s until " " -> u; ! OK