Input from Devices
Devices may be read in the same manner as a STRING file, (see the STRING verb for more information), with the exception of not being able to position to a point in the file. Devices are treated as continuous character streams and must be read serially (exceptions may occur if your system supports block devices).
The data read from a device is only echoed back to the device by PRO/5 if the device is a terminal, and only when the terminal is OPENed on channel 0 (this is performed by PRO/5 when it is started). If you want a terminal to echo data on a channel other than channel 0, you must send the 'BE' (begin echo) mnemonic on the desired channel.
Examples of Device Input
Description |
Example |
Read characters from channel 1 until one of the input terminating characters is encountered (defined in the CTL variable). |
READ (1)A$ |
Specify the maximum number of characters to read. |
>READ (1,SIZ=1)A$ |
Use the RECORD modifier to read from a device without PRO/5 scanning for terminators. The example retrieves one character from channel 1 and places it into A$ without modification. |
>READ RECORD(1,SIZ=1)A$ |
Modify input characters, using the TBL= option which performs translation character-by-character. This translation occurs on each character prior to PRO/5 scanning for field terminators |
0010 TABLE 7F 20 20 20 20 20 20 20 20 20 20 0A 20 20 |
Specify the device timeout, using the TIM= option to set the maximum number of seconds to wait for the first character and between characters. If a character is not received in the specified number of seconds, PRO/5 will generate an !ERROR=0 (busy device) and return without having modified your input variable in any manner |
0010 BEGIN; OPEN(1)FID(0); OPEN(2)"/dev/tty01" |
The length of the input field may be limited without terminating the input using the "LEN=" option. This will allow the input to continue until the length specified is reached. At that point, further input is ignored (the terminal bell rings if the device is a terminal) until a terminator is read.