WebTcpipScreenRecvPacketsUntilText Function

Action

Receives data from a given connection until rendered screen contains specified text. This function is only valid on open connections that have a screen renderer associated with them, as is the case with Telnet connections.

Include file

WebAPI.bdh

Syntax

WebTcpipScreenRecvPacketsUntilText(    in  hWeb        : number,
                                       in  nCol        : number,
                                       in  nRow        : number,
                                       in  sText       : string,
                                       in  nOptions    : number optional,
                                       in  nTextLength : number optional,
                                       out sRecv       : dstring optional ): boolean;

Return value

  • true if the operation was successful and data was received until specified text was rendered on screen

  • false otherwise

Parameter Description
hWeb Valid handle to a Web connection created by WebTcpipConnect. Web connection must be in Telnet mode (by a previous WebTcpipSetTelnetMode function call) and have a screen renderer associated with it.
nCol Column on rendered screen at which position the text should be compared.
nRow Row on rendered screen at which position the text should be compared.
sText Text value that should be compared against the rendered screen.
nOptions

By default the retrieved content has to be equal with the compared sVerify string, case-insensitively (optional). Comparison options are:

  • TELNET_FLAG_EQUAL: Comparison is made against both whole strings. (default)

  • TELNET_FLAG_CASE_SENSITIVE: Perform comparison case-sensitively.

  • TELNET_FLAG_IS_DIFFERENT: Negates the logical comparison.

  • TELNET_FLAG_IGNORE_WHITE_SPACE: All whitespaces in both compared strings are cut before comparison is performed.

  • TELNET_FLAG_CONTAINS: Compared string must occur within the retrieved content.

  • TELNET_FLAG_FROM_LEFT: The retrieved content only has to begin with the compared string.

  • TELNET_FLAG_TRIM_LEFT: Leading blanks are trimmed from retrieved content before comparison.

  • TELNET_FLAG_TRIM_RIGHT: Trailing blanks are trimmed from retrieved content before comparison.

  • TELNET_FLAG_TRIM_BOTH: Rendered text is trimmed from both sides before comparison.

  • TELNET_FLAG_FROM_RIGHT: Comparison is made from the right of the retrieved content.

nTextLength Length of rendered text that is to be compared (optional). By default this means the length of sText.
sRecv Output buffer for all binary data received from the connection until sText matches rendered screen portion including the last received packet which produced the desired screen content (optional).

Example

dcltrans
  transaction TInit
  begin
    StrSetHostCP(1148);// 1148  (IBM EBCDIC - International(500 + Euro))
  end TInit;
   
  transaction TMain
  var
    hWeb0     : number;
    iFieldPos : number;
  begin
    WebTcpipConnect(hWeb0, "My.TelnetHost.IP", WEB_PORT_TELNET); // Port: 23
    WebTcpipSetTelnetMode(hWeb0, TERMINAL_TYPE_3270, 80, 24, true,TELNET_MODEOPT_RFC_1576 | TELNET_MODEOPT_AUTO_RECV);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TerminalType);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TerminalType);
    WebTelnetRecvSubNegotiation(hWeb0, TELNET_OPT_TerminalType);
    WebTelnetSendTerminalType(hWeb0, "IBM-3278-2-E");
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_EndOfRecord);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_EndOfRecord);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TransmitBinary);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TransmitBinary);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_EndOfRecord);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_EndOfRecord);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TransmitBinary);
    WebTelnetSendCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TransmitBinary);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_DO, TELNET_OPT_TransmitBinary);
    WebTelnetRecvCommand(hWeb0, TELNET_CMD_WILL, TELNET_OPT_TransmitBinary);
    WebTelnetRecvRecord(hWeb0);
    WebTelnetRecvRecord(hWeb0);
    WebTelnetSendRecord(hWeb0,

      "\h88001181A600000B0100005000180050" // ····¦······P···P 00000000
 
      "\h001800168186000800F4F1F1F2F2F3F3" // ·········ôññòòóó 00000010
 
      "\hF4F4F5F5F6F6F7F7000D81870400F0F1" // ôôõõöö÷÷······ðñ 00000020
 
      "\hF1F2F2F4F40007818800010200178181" // ñòòôô··········· 00000030
 
      "\h01000050001801000100030004000909" // ···P············ 00000040
 
      "\h0C0780001B81858200090C0000000007" // ················ 00000050 
     
      "\h00000002B900250100F103C301360006" // ····¹·%··ñ·Ã·6·· 00000060
 
      "\h81990000001281970000080008000101" // ················ 00000070
 
      "\h000B0401C0C1000981A80200F0FFFFFF" // ····ÀÁ···¨··ð··· 00000080
      
      "\hFF000C81950000081108110101000F81" // ················ 00000090
 
      "\h80A687888185869997A89580");      // ·¦·······¨··    000000A0  
    WebTelnetRecvRecord(hWeb0);
    WebTcpipRecvPackets(hWeb0);
    WebTelnetRecvRecord(hWeb0);
    WebTelnetSendRecord(hWeb0, "\h7D5B6F115B6F" + StrToHostCP("1"));
    WebTcpipScreenRecvPacketsUntilStatus(hWeb0, "Keyboard Locked", "false");
    WebTelnetSendRecord(hWeb0, "\h7D5BF0115BF0" + StrToHostCP("12"));
    WebTcpipScreenRecvPacketsUntilText(hWeb0, 6, 22, "Choice:");    
    WebTelnetSendRecord(hWeb0, "\h7D5A5E115A5E" + StrToHostCP("12"));
    WebTcpipSetPacketBoundary(hWeb0, "\nFFEF");
    WebTcpipScreenRecvPacketsUntilField(hWeb0, 1, "");
    iFieldPos := WebTelnetScreenGetFieldIndex(hWeb0,16, 22);
    
    if iFieldPos = 1 then
      WebTcpipShutdown(hWeb0);
    end;
  end TMain;