Searches for a character pattern in a presentation space.
HCON Library
C (libg3270.a)
Pascal (libg3270p.a)
FORTRAN (libg3270f.a)
#include <g32_api.h>
struct g32_api *as;
char *pattern;
function g32srch(var as : g32_api;
pattern : stringptr) : integer; external;
EXTERNAL G32SEARCH
INTEGER AS(9), G32SEARCH
CHARACTER *XX PATTERN
RC = G32SEARCH(AS, PATTERN)
The g32_search function searches for the specified byte pattern in the presentation space associated with the application.
The search is performed from the row and column given in the g32_api structure to the end of the presentation space. Note that the row and column positions start at 1 (one) and not 0. If you start at 0 for row and column, an invalid position error will result.
The g32_search function is part of the Host Connection Program (HCON).
The g32_search function requires one or more adapters used to connect to a host.
In a DBCS environment, the g32_search function only searches the presentation space for an SBCS character pattern. This function does not support Katakana or DBCS characters.
In any given search pattern, the following characters have special meaning:
The string AB?DE matches any of ABCDE, AB9DE, ABxDE, but does not match ABCD, ABCCDE, or ABDE.
The string AB*DE matches any of ABCDE, AB9DE, ABCCDE, ABDE, but does not match ABCD, ABCDF, or ABC.
If the pattern needs to contain either a question mark or an asterisk as a literal character, these symbols must be preceded by two escape characters (\\? or \\*). For example, to search for the string, How are you today?, the pattern might be:
How are you today \\?
The backslash can be used as a literal character by specifying four backslash characters (\\\\) in the pattern. For example, to search for the string, We found the \., the pattern might be:
We found the \\\\.
If the pattern needs to contain either a question mark or an asterisk as a literal character, these symbols must be preceded by one escape character (\? or \*). For example, to search for the string, How are you today?, the pattern might be:
How are you today\?
The backslash can be used as a literal character by specifying two backslash characters (\\) in the pattern. For example, to search for the string, We found the \., the pattern might be:
We found the \\.
HCON application programs using the Pascal language interface must include and link both the C and Pascal libraries. Application programs using the FORTRAN language for the HCON API must include and link both the C and FORTRAN libraries.
AS | Specifies a g32_api equivalent structure as an array of integers. |
PATTERN | Specifies a string that is searched for in the presentation space. |
The following example fragment illustrates the use of the g32_search function in an api_3270 mode program in C language:
#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); . . .
/usr/include/g32_api.h | Contains data structures and associated symbol definitions. |
/usr/include/g32const.inc | Defines Pascal API constants. |
/usr/include/g32hfile.inc | Defines Pascal API external definitions. |
/usr/include/g32types.inc | Defines Pascal API data types. |