TAL Reference Manual

Statements
TAL Reference Manual526371-001
12-6
Examples of Assignment Statements
Examples of Assignment Statements
1. This example shows various assignment statements:
INT array[0:2]; !Declare an array
INT .ptr; !Declare a simple pointer
REAL real_var; !Declare a REAL variable
FIXED fixed_var; !Declare a FIXED variable
array[2] := 255; !Assign a value to ARRAY[2]
@ptr := @array[1]; !Assign address of ARRAY[1]
!to PTR
ptr := array[2]; !Assign value of ARRAY[2]
!to ARRAY[1], to which PTR
!points
real_var := 36.6E-3; !Assign a REAL value to a
!REAL variable
fixed_var := $FIX (real_var); !Convert a REAL value to
!FIXED and assign it to a
!FIXED variable
2. Assignment statements can assign character strings but not constant lists, so in
this example the three assignment statements together store the same value as
the one constant list in the declaration:
INT .b[0:2] := ["ABCDEF"]; !Declare and initialize
!with constant list
b[0] := "AB"; !Assignment statements
b[1] := "CD"; !cannot use constant lists
b[2] := "EF";
3. In this example, the first assignment statement (which contains assignment
expressions) is equivalent to the three separate assignments that follow it:
INT int1;
INT int2;
INT int3;
INT var := 16; !Declarations
int1 := int2 := int3 := var; !Assignment that contains
!assignment expressions
int1 := var; !Separate assignments
int2 := var;
int3 := var;