TAL Reference Manual

Simple Variables
TAL Reference Manual526371-001
6-3
Examples of Simple Variable Declarations
2. The following examples declare and initialize simple variables:
STRING y := "A"; !Character string
STRING z := 255; !Byte value
INT a := "AB"; !Character string
INT b := 5 * 2; !Expression
INT c := %B110; !Word value
INT(32) dblwd2 := %B1011101D; !Doubleword value
INT(32) dblwd3 := $DBL(%177775); !Standard function
REAL flt1 := 365335.6E-3; !Doubleword value
REAL(64) flt2 := 2718.2818284590452L-3; !Quadrupleword value
3. These examples declare FIXED simple variables and show how the fpoint affects
storage (and scaling):
FIXED(-3) f := 642987F; !Stored as 642; accessed
! as 642000
FIXED(3) g := 0.642F; !Stored as 642, accessed
! as 0.642
FIXED(2) h := 1.234F; !Stored as 123; accessed
! as 1.23
4. This example illustrates use of constants (any level) and variables (local or
sublocal only) as initialization values:
INT global := 34; !Only constants allowed
! in global initialization
PROC mymain MAIN;
BEGIN
INT local := global + 10; !Any expression allowed
INT local2 := global * local; !in local or sublocal
FIXED local3 := $FIX(local2); !initialization
!Lots of code
END; !End of MYMAIN procedure