Terminal control

The terminal control classes, IccTerminal, IccTermId, and IccTerminalData, allow you to send data to, receive data from, and find out information about the terminal belonging to the CICS® task.

An IccTerminal object is used to represent the terminal that belongs to the CICS task. It can only be created if the transaction has a 3270 terminal as its principal facility. The IccTermId class is used to identify the terminal. IccTerminalData, which is owned by IccTerminal, contains information about the terminal characteristics.

Sending data to a terminal

The send and sendLine methods of IccTerminal class are used to write data to the screen. Alternatively, you can use the "<<" operators to send data to the terminal.

Before sending data to a terminal, you may want to set, for example, the position of the cursor on the screen or the color of the text. The set... methods allow you to do this. You may also want to erase the data currently displayed at the terminal, using the erase method, and free the keyboard so that it is ready to receive input, using the freeKeyboard method.

Receiving data from a terminal

The receive and receive3270data methods of IccTerminal class are used to receive data from the terminal.

Finding out information about a terminal

You can find out information about both the characteristics of the terminal and its current state.

The data object points to the IccTerminalData object that contains information about the characteristics of the terminal. The methods described in IccTerminalData on page IccTerminalData class allow you to discover, for example, the height of the screen or whether the terminal supports Erase Write Alternative. Some of the methods in IccTerminal also give you information about characteristics, such as how many lines a screen holds.

Other methods give you information about the current state of the terminal. These include line, which returns the current line number, and cursor, which returns the current cursor position.

Example of terminal control

This sample program demonstrates how to use the IccTerminal, IccTermId, and IccTerminalData classes. This program can be found in the samples directory (see Sample source code) as file ICC$TRM.

#include "icceh.hpp"
#include "iccmain.hpp"

The first two lines include the header files for the Foundation Classes and the standard main function that sets up the operating environment for the application program.

void IccUserControl::run()
{
  IccTerminal& term = *terminal();
  term.erase();

The run method of IccUserControl class contains the user code for this example. As a terminal is to be used, the example starts by creating a terminal object and clearing the associated screen.

  term.sendLine( "First part of the line..." );
  term.send( "... a continuation of the line." );
  term.sendLine( "Start this on the next line" );
  term.sendLine( 40, "Send this to column 40 of current line" );
  term.send( 5, 10, "Send this to row 5, column 10" );
  term.send( 6, 40, "Send this to row 6, column 40" );

This fragment shows how the send and sendLine methods are used to send data to the terminal. All of these methods can take IccBuf references (const IccBuf&) instead of string literals (const char*).

  term.setNewLine();

This sends a blank line to the screen.

  term.setColor( IccTerminal::red );
  term.sendLine( "A Red line of text.");
  term.setColor( IccTerminal::blue );
  term.setHighlight( IccTerminal::reverse );
  term.sendLine( "A Blue, Reverse video line of text.");

The setColor method is used to set the colour of the text on the screen and the setHighlight method to set the highlighting.

  term << "A cout sytle interface... " << endl;
  term << "you can " << "chain input together; "
       << "use different types, eg numbers: " << (short)123 << " "
       << (long)4567890 << " " << (double)123456.7891234 << endl;
  term << "... and everything is buffered till you issue a flush."
       << flush;

This fragment shows how to use the iostream-like interface endl to start data on the next line. To improve performance, you can buffer data in the terminal until flush is issued, which sends the data to the screen.

  term.send( 24,1, "Program 'icc$trm' complete: Hit PF12 to End" );
  term.waitForAID( IccTerminal::PF12 );
  term.erase();

The waitForAID method causes the terminal to wait until the specified key is hit, before calling the erase method to clear the display.

  return;
}

The end of run, which returns control to CICS.

See Appendix C. Output from sample programs for the expected output from this sample program.

[[ Contents Previous Page | Next Page Index ]]