终端控制
终端控制类 IccTerminal 、IccTermId 和 IccTerminalData 允许您发送数据、接收数据以及查找属于 CICS®终端信息。 IccTerminal用于表示属于 CICS终端。 仅当事务将 3270 终端作为其主要设施时,才能创建此文件。 IccTermId用于识别终端。 IccTerminalData 由IccTerminal 拥有,包含有关终端特性的信息。
将数据发送到终端
IccTerminal 类的 send 和 sendLine 方法用于将数据写入屏幕。
set ... 方法允许您执行此操作。 您可能还希望使用 擦除 方法擦除当前在终端上显示的数据,并使用 freeKeyboard 方法释放键盘,以使其准备好接收输入。
从终端接收数据
IccTerminal 类的 receive 和 receive3270data 方法用于从终端接收数据。
查找有关终端的信息
您可以查找有关终端的特征及其当前状态的信息。
数据对象指向 IccTerminalData ,后者包含终端特征信息。 IccTerminalData 中的方法可以让您发现屏幕高度或终端是否支持擦除写入替代。 IccTerminal 中的某些方法还向您提供有关特征的信息,例如,屏幕保留的行数。
其他方法为您提供有关终端当前状态的信息。 其中包括返回当前行号的 line和返回当前光标位置的 cursor。
终端控件示例
我们提供了一份示例程序,演示如何使用 IccTerminal 、IccTermId 和 IccTerminalData 类。 可以在 C++ 样本程序(作为文件 ICC$TRM) 中找到此程序及其期望的输出。
图 1 显示了前两行,其中包括用于基础类的头文件以及用于为应用程序设置操作环境的标准 main 函数。
#include "icceh.hpp"
#include "iccmain.hpp"在图2中 , IccUserControl 运行方法包含此示例的用户代码。 作为要使用的终端,示例通过创建终端对象并清除关联的屏幕来启动。
void IccUserControl::run()
{
IccTerminal& term = *terminal();
term.erase();图 3 中的代码片段显示了如何使用 send 和 sendLine 方法将数据发送到终端。 所有这些方法都可以使用 IccBuf 引用 IccBuf& 而不是字符串字面量(const char*)。
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" );图 4 将空白行发送到屏幕。
term.setNewLine();在 图 5中, setColor 方法用于设置屏幕上文本的颜色,而 setHighlight 方法用于设置突出显示。
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.");图 6 中的代码片段显示了如何使用类似 iostream 的接口 endl 在下一行上启动数据。 为了提高性能,您可以在终端中缓冲数据,直到发出 flush ,这会将数据发送到屏幕。
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;在图7中 waitForAID导致终端等待直到按下指定的键,然后调用 erase方法清除显示。
term.send( 24,1, "Program 'icc$trm' complete: Hit PF12
to End" );
term.waitForAID( IccTerminal::PF12 );
term.erase();图 8 显示了 run的结束,这会将控制权返回给 CICS。
return;
}