pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
Topics:
• Pointer Assignment (page 203)
• Assigning Numbers to FIXED Variables (page 203)
• Assigning Character Strings (page 203)
• Examples (page 203)
Pointer Assignment
The result of applying an @ operator to a variable or pointer is an address whose data type is one
of the pTAL address types.
In an assignment statement, one of the following must be true:
• Both operands are the same address type.
• Neither operand is an address type.
You can use type-conversion built-in routines to convert some address types to other address types.
For more information:
See ...Topic
Chapter 15 (page 274)Type-conversion built-in routines
Chapter 5 (page 69)Converting addresses
Chapter 10 (page 161)Pointers
Assigning Numbers to FIXED Variables
When you assign a number to a FIXED variable, the system scales the value up or down to match
the fpoint value. If the system scales the value down, you lose some precision depending on
the amount of scaling; for example:
FIXED(2) a;
a := 2.348F; ! System scales value to 2.34F
If the ROUND directive is active, the system scales the value as needed, then rounds the value
away from zero as follows:
(IF value < 0 THEN value - 5 ELSE value + 5) / 10
For example, if you assign 2.348F to a FIXED(2) variable, the ROUND directive scales the value
by one digit and then rounds it to 2.35F.
Assigning Character Strings
You can assign a character string to STRING, INT, or INT(32) variables.
If you assign a one-character string such as "A" to an INT simple variable, the system places the
value in the right byte of a word and 0 in the left byte. To store a character in the left byte, assign
the character and a space, as in:
"A "
If you assign a character string to a FIXED, REAL, or REAL(64) variable, the compiler issues a type
incompatibility error.
Examples
Example 143 Assignment Statements
INT array[0:2]; ! Array
INT .ptr; ! Simple pointer
REAL real_var; ! REAL variable
Assignment 203