g32_send_keys Function

Purpose

Sends key strokes to the terminal emulator.

Libraries

HCON Library
C (libg3270.a)
Pascal (libg3270p.a)
FORTRAN (libg3270f.a)

C Syntax

#include <g32_api.h>
#include <g32_keys.h>

g32_send_keys ( as buffer)

struct g32_api *as;
char *buffer;

Pascal Syntax

const
%include /usr/include/g32keys.inc

function g32sdky (var  as : g32_api;
   buffer : stringptr) : integer; external;

FORTRAN Syntax

EXTERNAL G32SENDKEYS
INTEGER AS(9), G32SENDKEYS
CHARACTER *XX BUFFER

RC = G32SENDKEYS( AS BUFFER)

Description

The g32_send_keys function sends one or more key strokes to a terminal emulator as though they came from the keyboard. ASCII characters are sent by coding their ASCII value. Other keys (such as Enter and the cursor-movement keys) are sent by coding their values from the g32_keys.h file (for C programs) or g32keys.inc file (for Pascal programs). FORTRAN users send other keys by passing the name of the key through the G32SENDKEYS buffer.

Note: The g32_send_keys function can only send 128 characters per call. The g32_send_keys function can be chained when more than 128 characters must be sent.

The g32_send_keys function can only be used in API/3270 mode.

The g32_send_keys function is part of the Host Connection Program (HCON).

The g32_send_keys function requires one or more adapters used to connect to a host.

In a DBCS environment, the g32_send_keys function only sends SBCS keystrokes, including ASCII characters, to a terminal emulator. DBCS characters are ignored.

C Parameters

Item Description
as Specifies a pointer to the g32_api structure. Status is returned in this structure.
buffer Specifies a pointer to a buffer of key stroke data.

Pascal Parameters

Item Description
as Specifies the g32_api structure. Status is returned in this structure.
buffer Specifies a pointer to a string containing the keys to be sent to the host. The string must be at least as long as indicated in the g32_api structure.

FORTRAN Parameters

Item Description
AS Specifies the g32_api equivalent structure as an array of integers.
BUFFER The character array containing the key sequence to send to the host. A special emulator key can be sent by the g32_send_keys function as follows:
BUFFER = 'ENTER'//CHAR(0)
RC = G32SENDKEYS (AS,BUFFER)

The special emulator strings recognized by the g32_send_keys function are as follows:

CLEAR   DELETE  DUP     ENTER
EOF     ERASE   FMARK   HOME
INSERT  NEWLINE RESET   SYSREQ
LEFT    RIGHT   UP      DOWN
LLEFT   RRIGHT  UUP     DDOWN
TAB     BTAB    ATTN
PA1     PA2     PA3
PF1     PF2     PF3     PF4
PF5     PF6     PF7     PF8
PF9     PF10    PF11    PF12
PF13    PF14    PF15    PF16
PF17    PF18    PF19    PF20
PF21    PF22    PF23    PF24
                        CURSEL

Return Values

Item Description
0 Indicates successful completion.
-1 Indicates an error has occurred.
  • The errcode field in the g32_api structure is set to the error code identifying the error.
  • The xerrinfo field can be set to give more information about the error.

Examples

Note: The following example is missing the required g32_open and g32_alloc functions which are necessary for every HCON workstation API program.

The following example fragment illustrates, in C language, the use of the g32_send_keys function in an api_3270 mode program:

#include <g32_api.h>            /* API include file */
*include <g32_keys.h>
main()
{
struct g32_api *as;             /* g32 structure */
char *buffer;                    /* pointer to char string */
int return;                      /* return code */
char *malloc();                  /* C memory allocation
                                      function */
.
.
.
return = g32_notify(as,1);       /* Turn notification on */
buffer = malloc(10);
return = g32_get_cursor(as);     /* get location of cursor */
printf (" The cursor position is row: %d col: %d/n",
        as -> row, as -> column);
/* Get data from host starting at the current row and column */
as -> length = 10;              /* length of a pattern on host */
return = g32_get_data(as,buffer); /* get data from host */
printf("The data returned is <%s>\n",buffer);
/* Try to search for a particular pattern on host */
as ->row =1;                     /* row to start search */
as ->column =1;                  /* column to start search */
return = g32_search(as,"PATTERN");
/*Send a clear key to the host */
return = g32_send_keys(as,CLEAR);
/* Turn notification off */
return = g32_notify(as,0);
.
.
.