The program sends data to the terminal using the SOK3 key. This key uses a co-routine protocol. SOK3 remembers a number called the output limit.
SOK3(0,data; ==> c;,,,SOK3) "Write in line mode"
1: EBCDIC line mode
2: screen mode
If mode > 2, c=1 and data_in is absent.
If mode is absent, c=2.
Data_out is transmitted to the terminal in the selected character set. Limit_in is ignored and data_in is absent. c=0 normally, c=kt+1 if the data connection is broken.
This operation carries on an exchange of data. Data_out is appended to the command buffer (thus allowing a command to be transmitted over more than one call). When the command buffer is of the form ((4,command_count), (command_count, command)), the command is obeyed (and the command buffer is emptied) before the operation returns. If it is a read command, the data read is put into the input buffer.
Data from the beginning of the input buffer is removed from there and returned as data_in. Data_in will not be longer than the integer limit_in. If the input buffer wouldn't all fit in data_in, limit_out=0 (indicating there is more input that must be accepted before any more output can be sent), otherwise limit_out > 3.
The command_count must all be transmitted in a single call. (Limit_out is never 1, 2, or 3.)
SOK3 considers the current command to be chained from the previous command. After a command is obeyed, it naturally becomes the previous command. If the previous command is "none", the current command is considered unchained. A null command (command_count = 0) has no effect except to set the previous command to "none".
Return codes:
c=1. 3270 screen mode is not supported. The command buffer is empty and the previous command is "none".
c=2. Mode and limit_in are not present. "data_in" is null.
c=3. The command buffer was empty and data_out was more than 0 and less than 4 bytes long. (Command_count must be transmitted all at once.) The previous command is set to "none", the command buffer remains empty, and data_in is null.
c=4. Command too long for command_count. Only one command can be transmitted at once. No commands are obeyed, data_in is null, the command buffer is emptied, and the previous command is set to "none".
c=5. Command_count exceeds an implementation-defined limit. This limit is always somewhat larger than the screen size. The outcome is the same as for c=4.
c=6. The command code is not one of the valid codes listed below. The outcome is the same as for c=4.
c=7. The command code was for a read command but it was followed by extraneous data. The outcome is the same as for c=4.
c=8. "Op-check" A buffer address was specified that is not supported by this device, wor the WCC was X'88'. The command buffer is emptied and the previous command is set to "none".
c=9. There was an unrecoverable device error. The user must reconstruct the screen. The command buffer is emptied and the previous command is set to "none".
c=10. The input buffer is nonempty but limit_in is zero. (The buffer may have just become nonempty as a result of a read command.)
c=11. "Command reject" The command is not supported by this device. The command buffer is emptied and the previous command is set to "none".
c=kt+1. The connection to the terminal is severed. No data or keys are returned.
c=kt+5. The command buffer does not yet contain a complete command.
Non-null commands begin with a one-byte command code which is one of the following hexadecimal values. (Values in parentheses are the corresponding hexadecimal 3274B command codes for reference.)
F3 (11) Write Structured Field (not supported by all devices)
F5 (05) Erase/Write
7E (0D) Erase/Write Alternate (Not supported by all devices)
6F (0F) Erase All Unprotected
F2 (02) Read Buffer
F6 (06) Read Modified
SOK3(kt+1) Signal EOF