Re: eflastkey and internal globals
Posted in 1991
Harry Bochner, in your mail you wrote: > > Great! I've often wished there was a way to do this! > It turns out, however, that it's a bit harder for us RDS users: the eflastkey > variable isn't directly accessible to interpreted 4gl code. It is there, > however, so if you want it, you should be able to link in a C routine that > returns its value ... > We've already done that... see below. > More generally, though, does anyone have a list of useful undocumented global > variables that we might want to tap into? For instance, the number of records > found by a select must be available somewhere, since perform displays it for > you, but how do you access it? (Yes, you could do a 'select count(*)', but > that's much slower.) > Have you tried SQLCA.SQLERRD[3] ??? Anyway here are some functions that you may find useful... Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip /* usr_funcs.c * This module contains 'C' functions that are used by Informix-4GL * at run-time. They should work with both RAPID and COMPILED 4GL. */ #include <decimal.h> #include <sqlfm.h> #include <stdio.h> /****************************************************************************** * This function returns the absolute value of an Informix decimal type. * ******************************************************************************/ decabs(arg) int arg; { dec_t dm; popdec(&dm); dm.dec_pos = 1; retdec(&dm); return(1); } /****************************************************************************** * This function returns the last key hit. * ******************************************************************************/ dblastkey(arg) int arg; { extern short eflastkey; retshort(eflastkey); return(1); } /****************************************************************************** * This function prints whatever is on the screen. * ******************************************************************************/ #define bool char #define CHAR short #define _ATTRIBUTE (0x7f00) #define _CHARACTER (0x00ff) #define _GRAPHMODE (0x8000) typedef struct window { short _cury, _curx; short _maxy, _maxx; short _begy, _begx; short _flags; bool _clear; bool _leave; bool _scroll; CHAR * *_y; short *_firstch; short *_lastch; short _attr; } WINDOW; extern _EFwindow *topwin, *botwin, *_Wscreen; extern WINDOW *_efbigwin; extern char *GB; dbprtscr(arg) int arg; { register FILE *fp; register _EFwindow *scr; register WINDOW *win; register CHAR **line, *data; register int y, x; register char c; char *getenv(), *dbprint; dbprint = getenv("DBPRINT"); if (dbprint == NULL) dbprint = "lp -s"; if (topwin == _Wscreen) /* the user is looking at the "screen" */ win = (WINDOW * ) _Wscreen->win; else { /* the user is looking at the one or more "windows" */ win = _efbigwin; for (scr = botwin; scr != (_EFwindow * )0; scr = (_EFwindow * )scr->upper) { overwrite((WINDOW * ) scr->win, win); } } if ((fp = popen(dbprint, "w")) != (FILE * )0) { for (y = 0, line = win->_y; y < win->_maxy; y++, line++) { for (x = 0, data = *line; x < win->_maxx; x++, data++) { c = (char) *data & _CHARACTER; if ((*data & _GRAPHMODE) && *GB) { if (c == GB[0]) c = '+'; else if (c == GB[1]) c = '+'; else if (c == GB[2]) c = '+'; else if (c == GB[3]) c = '+'; else if (c == GB[4]) c = '-'; else if (c == GB[5]) c = '|'; } (void)fputc(c, fp); } (void)fputc('\\n', fp); } (void)pclose(fp); } return 0; } Here --------- Snip Here --------- Snip Here --------- Snip Here --------- Snip DAS -- David A. Snyder @ UE&C - Catalytic in Philadelphia, PA UUCP: ..!uunet!trac2000!das INTERNET: das@ueci.com