TAL Programmer's Guide
Scanning Arrays
Using Arrays
7–22 096254 Tandem Computers Incorporated
Computing the Offset of a Character
The following SCAN WHILE example finds the offset of the first name from the
beginning of the array. It scans left to right from the address following the comma,
looking for a character other than a space or a zero. It stops at the beginning of the
first name and stores that address in the next-address pointer START_FIRST_NAME.
The assignment statement then computes the offset and assigns it to OFFSET:
SCAN comma[1] WHILE " " -> @start_first_name;
offset := @start_first_name '-' @sptr;
Smith, Maurice
378
START_LAST_NAME
SPTR[0]
Computing the Length of a Character String
The following SCAN UNTIL example finds the length of the name contained in the
array. It scans left to right from the address stored in START_FIRST_NAME by the
preceding scan, looking for a space or a zero. It stores in END_FIRST_NAME the
address where the space occurs. The assignment statement then computes the length
of the entire name and assigns it to LENGTH:
SCAN start_first_name UNTIL " " -> @end_first_name;
length := @end_first_name '-' @start_last_name;
Smith, Maurice
379
START_FIRST_NAME
END_FIRST_NAME
START_LAST_NAME