TAL Programmer's Guide

Declaring Simple Variables
Using Simple Variables
6–2 096254 Tandem Computers Incorporated
Initializing Simple Variables You can initialize a simple variable of any data type (except UNSIGNED) when you
declare it. Following the identifier in the declaration, specify an assignment operator
(:=) and an initialization value:
INT var := 45; !Declare VAR and initialize
! it with the value 45
You can initialize a simple variable with character strings or numbers.
Initializing With Character Strings
When you initialize with a character string, specify a character string that has the same
number of bytes as the simple variable or fewer. Each character in a character string
requires one byte of contiguous storage. The value of any uninitialized bytes are
undefined. In the following diagram, the question mark denotes an undefined value:
INT(32) chars := "ABC"; "A" "B"
"C" ?
350
Initializing With Numbers
When you initialize with a number, you must specify a value of the same data type as
the variable. In other words, specify a value that is in the range and format described
for each data type in “Simple Variables by Data Type” in this section.
For example, to initialize a REAL simple variable, specify a REAL value. To initialize
an INT(32) simple variable, specify an INT(32) value:
REAL flt_num := 365335.6E-3;
INT(32) dbl_num := 256D;
Specifying Number Bases
When you initialize a STRING, INT, or INT(32) variable with a number, you can
specify integer constants in binary, octal, decimal, or hexadecimal base. The default
number base in TAL is decimal. Table 6-1 describes the format of each number base.
Table 6-1. Number Base Formats
Number Base Prefix Digits Allowed Example
Decimal None 0 through 9 46
Octal % 0 through 7 %57
Binary %B 0 or 1 %B101111
Hexadecimal %H 0 through 9, A through F %H2F