Re: Keeping Track of Windows
Posted in 1994
Topics: High Availability & Replication, Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Stephen Foster (Stephen.Foster@newcastle.ac.uk) wrote: > [stuff deleted] Here is some C source to do it. It allows you to push a window, update its contents and then pop it again. I was using this to update a window called zzkeys_window that contained a display of currently active function keys. My memory is a bit hazy on how it worked (old age?) since it has been a couple of years since I have used 4GL. I seem to recall that you need an include file from the C development system (either "sqlfm.h" or "sqlhdr.h"). If you don't have this then try to "borrow" a copy of the header files from somewhere. I had a #define for USING_RDS depending on whether the environment was RDS or C development system. My only warning is that it munges around with Infomix's internal window pointers so look out! The protocol is: Call the "push" routine within 4GL. Update the window contents to your hearts content. Call the "pop" routine. Don't go switching windows (via CURRENT WINDOW IS) within a "push"/"pop" pair. The results may be unpredicatable. The code will require a few small changes to fit your purpose - but there is no such thing as a free lunch! If you decide to use it and can't get it to go, mail me. David. #include <stdio.h> #include "sqlfm.h" #if defined(USING_RDS) #include "sqlhdr.h" #endif #if defined(USING_RDS) static _EFwindow *_Wzzkeys_window = NULL; extern _EFwindow *topwin; #else extern _EFwindow *_Wzzkeys_window; #endif /* * Keys window. */ static _EFwindow *window_above; /* * Window immediately above the keys window in the list of windows. */ static _EFwindow *window_below; /* * Window immediately below the keys window in the list of windows. */ /*------------------------------------------------------------------------------ Routine name : pop_keys_window Description : Restore the keys window into its previous position in the list of windows. Parameters : None. Return values : None. Remarks : (1) this routine assumes that the routine push_keys_window has been called prior to being called and that the keys window is the current window. ------------------------------------------------------------------------------*/ static void pop_keys_window() { /**/ /* * Make the window below the keys window the current window. */ if (_Wzzkeys_window->lower != NULL) { _efwcur(_Wzzkeys_window->lower); } /* * Re-order the list of windows in three parts. * * Part 1 : Set the windows that the keys window points to to point to * one another rather than the keys window. */ if (_Wzzkeys_window->lower != NULL) { _Wzzkeys_window->lower->upper = _Wzzkeys_window->upper; } if (_Wzzkeys_window->upper != NULL) { _Wzzkeys_window->upper->lower = _Wzzkeys_window->lower; } /* * Part 2 : Set the keys window to point to the window that used to be * above it and the window that used to be above it to point * back to it. */ if ((_Wzzkeys_window->upper = window_above) != NULL) { window_above->lower = _Wzzkeys_window; } /* * Part 3 : Set the keys window to point to the window that used to be * below it and the window that used to be below it to point * back to it. */ if ((_Wzzkeys_window->lower = window_below) != NULL) { window_below->upper = _Wzzkeys_window; } } /* pop_keys_window */ /*------------------------------------------------------------------------------ Routine name : push_keys_window Description : Note the current position in the list of windows of the keys window and make it the current window. Parameters : None. Return values : None. ------------------------------------------------------------------------------*/ static void push_keys_window() { /**/ #if defined(USING_RDS) /* * If the keys window has yet to be identified ... */ if (_Wzzkeys_window == NULL) { /* * ... establish where it is. */ for (_Wzzkeys_window = topwin; (_Wzzkeys_window != NULL); _Wzzkeys_window = _Wzzkeys_window->lower) { if (!(strcmp(_Wzzkeys_window->formname , KEYS_WINDOW_NAME))) { /* * Keys window has been found so stop looking! */ break; } } /* * If the window was not found ... */ if (_Wzzkeys_window == NULL) { /* * ... log an error ... */ sprintf(zzerror_message , "push_keys_window; could not find keys window"); (void) zzlog_error_message(0); /* * ... but use the topmost but one window! */ _Wzzkeys_window = topwin->lower; } } #endif /* * Note the windows above and below the keys window. */ window_above = _Wzzkeys_window->upper; window_below = _Wzzkeys_window->lower; /* * Make the keys window the current window. */ _efwcur(_Wzzkeys_window); } /* push_keys_window */ #if defined(USING_RDS) /*------------------------------------------------------------------------------ Routine name : zzpop_keys_window Description : Restore the keys window into its previous position in the list of windows. Parameters : fgl_argc - the number of parameters on 4GL's parameter stack. Return values : (result) - (1) the number of values pushed onto 4GL's return stack. Remarks : (1) this routine is provided to allow a 4GL module being used as part of the RDS to play about with the position of the keys window. ------------------------------------------------------------------------------*/ int zzpop_keys_window(fgl_argc) int fgl_argc; { /**/ if (fgl_argc != 0) { zzarg_mismatch("zzpop_keys_window" , fgl_argc); } pop_keys_window(); return(0); } /* zzpop_keys_window */ #endif #if defined(USING_RDS) /*------------------------------------------------------------------------------ Routine name : zzpush_keys_window Description : Note the current position in the list of windows of the keys window and make it the current window. Parameters : fgl_argc - the number of parameters on 4GL's parameter stack. Return values : (result) - (1) the number of values pushed onto 4GL's return stack. Remarks : (1) this routine is provided to allow a 4GL module being used as part of the RDS to play about with the position of the keys window. ---------------------------------