HP RPG/XL Programmer's Guide (30318-90001)
4- 2
the Calculation Specification operations DSPLY or DSPLM.
The READ/EXCPT method is more flexible but requires more coding. DSPLY
and DSPLM are simpler to use and they justify numeric input data. DSPLM
also displays data from message files.
Using READ and EXCPT. One method of using a terminal to read and display
data is to use the Calculation Specification operations, READ and EXCPT.
You can use one READ operation to read several fields at once. EXCPT
performs exception output to $STDLST.
If you want to reassign $STDIN and $STDLST to other devices, enter the
appropriate operating system FILE equation(s) before running the program.
For example, the following FILE equation creates the DATES file on disc
and redirects $STDLST to it (see Figure 4-2 for an example of how $STDLST
is used in the program),
:FILE STDLIST=DATES;SAVE;DEV=DISC;REC=-10,25,F,ASCII;DISC=25
Figure 4-2 shows how to use READ and EXCPT to read data from and write
data to a terminal. The File Description Specifications assign the files
INPUT and OUTPUT to the system-defined files, $STDIN and $STDLST,
respectively. The READ operation reads a date in the format, MMDDYY,
from the terminal. The date is converted to a YYMMDD format and this
converted date is displayed using EXCPT (exception output).
Figure 4-2. Using READ and EXCPT to Read and Display Terminal Data
Comments
1 This line defines the input file, INPUT, and assigns it to the
system-defined file, $STDIN.
2 This line defines the output file, OUTPUT, and assigns it to the
system-defined file, $STDLST.
3 This line begins the input record description for the file,
INPUT.
4 This line reads 6 characters from the terminal and saves them in
the field, MMDDYY.