Getting Started with TRANSACT (32247-90007)
Chapter 2 39
Using Character Mode I/O
Adding Data to a Dataset
Figure 2-2. Interactive Data Entry to a Dataset
The program repeats, or loops, indefinitely. When the last customer has been added, The
user stops the loop by entering the special character “]”. This character is reserved in
Transact to signify the end of user interaction.
The program called for the zipcode to be entered, but we see that the user was not
prompted for it. The reason is not a bug in the program. Instead, the comma entered
between the city and state sent an unexpected message to the Transact processor.
Transact allows user input to be stacked. That is, users who know what the program is
going to ask for can enter the data in advance. The default field separator for Transact is
the comma.
Thus our program did not work correctly. When we responded to the CITY-STATE prompt,
Transact associated San Jose with CITY-STATE and associated CA. with ZIPCODE.
The following program gets around this problem by changing the default field separator.
Figure 2-3. Changing the Default Input Field Delimiter
CUST-NO> 301
NAME> Joe's Bike Shop
STREET-ADDR> 1243 East Julian
CITY-STATE> San Jose, Ca.
CUST-NO> ]
EXIT/RESTART(E/R)?>
END OF PROGRAM
:
1 system ex9,base=orders(";");
2 set(delimiter) "/";
3 level;
4 prompt cust-no:
name:
street-addr:
city-state:
zipcode;
5 put customer;
6 end;