pTAL Conversion Guide

Statements
pTAL Conversion Guide527302-002
15-26
USE Statement
In Example 15-38 on page 15-26, the data type of t_start and of t_end is
CBADDR. Do not apply the @ operator to t_start or t_end in an arithmetic
expression. 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.
You can compile the in Example 15-38 on page 15-26 with the TAL compiler by
including this define in your code:
DEFINE CBADDR = INT#;
USE Statement
TAL
A USE statement associates an identifier with a TNS stack register. The TAL compiler
reserves the stack register for your program’s use and does not use it for dynamic
expression evaluation. You can reserve simultaneously a maximum of three variables.
pTAL
A USE statement does not explicitly associate an identifier with a native register. The
native compiler allocates, accesses, and optimizes variables declared in USE
statements just as it does INT variables. Do not write pTAL code that depends on
where or how pTAL allocates or accesses USE variables.
USE statements in pTAL have the same effect on FOR loop optimizations as they do in
TAL with respect to:
The value of the control variable when the loop terminates
Whether the FOR loop limit is recalculated before each iteration
Example 15-38. Scanning Data in P-Relative Arrays (pTAL)
STRING s = 'P' := [
1, "msg1.",
2, "msg2.",
3, "msg3.",
0 ]; ! STRING P-relative array s
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 c
SCAN s[t_start '-' @s] ! Find end of message
UNTIL z -> t_end;