3270 Data Stream Programming

Control Characters

 

Introduction

The 3270 data stream makes use of a small but powerful group of command codes that allow us to program the operation of the terminal.  Each command consists of a one byte command code followed by zero  to three parameter bytes.  The following table gives us a summary of these command codes.

Command Name Value Parameter 1 Parameter 2 Parameter 3
SF 1D Attribute Character    
SBA 11 Address Byte 1 Address Byte 2  
IC 13      
PT 05      
RA 3C Address Byte 1 Address Byte 2 Character To Repeat
EUA 12 Address Byte 1 Address Byte 2  

SF - Start Field

The Start Field command is the most often used command in a 3270 data stream.  It signals the 3270 that we are beginning the definition of a new field.  The SF command is always followed by a Field Attribute Character.  If we forget to place the Attribute Character in our data stream, the 3270 will use whatever follows the SF command as an attribute character.  Although the SF command is in the data stream, it does not take up a buffer position but remember the Attribute Character does take up a buffer position.

SBA - Set Buffer Address

The Set Buffer Address command is also a very common command code in 3270 data streams.  When we are sending a data stream to the 3270, it uses the concept of a buffer position to determine where to place the incoming data.  This means that we do not have send 1920 characters to the 3270 each time we write out a new screen.  It also means that we do not have to send out the characters in any specific order.  We do have to remember that it is possible to overlay something we wrote into the buffer earlier from the same data stream.  

An example of the SBA command would be to set the buffer position to line 4, column 1.  We would use the SBA followed by the encoded buffer position for offset 240 ( 3 * 80).  I will explain a little later how buffer position are encoded within a data stream.

IC - Insert Cursor

The Insert Cursor command instructs the 3270 to place the visible cursor at the current buffer position.  If we wanted to place the cursor at a specific row and column, we would probably first use a SBA command to set the buffer position followed by the IC command to place the cursor.  If multiple IC commands are used in a data stream, only the last one is used.

PT - Program Tab

This command instructs the 3270 to advance the buffer position to the next unprotected field.  This command is used for modifying the contents of a 3270 buffer. 

RA - Repeat To Address

The Repeat To Address command is a very useful command for shrinking the size of the data stream being sent to the 3270 terminal.  This command was very useful for remote terminals over slow connections.  This command says start at the current buffer position and repeat the same character over and over until you reach the specified buffer position.

For example if we wanted to print a line of 60 asterisks (*), we would first us a SBA command to position the starting position, possibly followed by a SF/Attribute combination.  We would then use a RA command.  The good news is we would get our line of 60 of the same character but instead of sending 60 bytes, we would only have to send 4 bytes.

This command can be used to clear the contents of the buffer by the following sequence:

SBA (Row 1, Col 1), RA (Row 1, Col 1, ' ')   This says to start in the first buffer position and insert a blank character until you get back to the first position (remember the buffer position will wrap when it reaches the end).

EUA - Erase Unprotected To Address

The EUA command is used to modify a screen already loaded in a 3270 buffer.  It will erase the contents of all unprotected fields beginning with the current buffer position until the specified buffer position is reached.  This is another of the bandwidth saving instructions.

Next Page