TAL Programmer's Guide

Modular Programming Example
Sample Programs
096254 Tandem Computers Incorporated A–11
Example A-6a. D-Series Mainline Module (Page 2 of 2)
WHILE (i < $OCCURS(in_rec.name)) AND (ch_ptr <> ",") DO
BEGIN
@ch_ptr := @ch_ptr[1];
i := i + 1;
END;
out_rec.name.last_name ':=' in_rec.name FOR i BYTES;
IF ch_ptr = ',' THEN !Copy first name
BEGIN
@ch_ptr := @ch_ptr[1]; !Advance past comma
out_rec.name.first_name ':=' ch_ptr FOR
$OCCURS(in_rec.name) '-' i '-' 1 BYTES;
END;
out_rec.address ':=' in_rec.address !Copy address
FOR $OCCURS(in_rec.address) BYTES;
END;
?SECTION convert
PROC convert;
BEGIN
INT record_count := 0;
STRUCT .in_buffer (in_rec_def);
STRUCT .out_buffer (out_rec_def);
WHILE (read_in (in_buffer:$LEN(in_rec_def))) <> 1 !EOF! DO
BEGIN !Read record,
! return EOF
CALL out_init (out_buffer:$LEN(out_rec_def));
!Initialize output
CALL record_convert (in_buffer, out_buffer);
CALL write_out (out_buffer:$LEN(out_rec_def));
record_count := record_count + 1;
END; !Of WHILE loop
!EOF
CALL msg (msg_eof, record_count);
END; !Of CONVERT
?SECTION end_of_code_sections
PROC tprconv MAIN;
BEGIN
CALL file_init; !In INITIALIZATION_MODULE
CALL convert;
CALL close_all;
END;
?NOMAP