Re: 4GL: How to access a global array from a C function
Posted in 1997
On Thu, 20 Nov 1997, Richard Spitz wrote: } Is there a way how I can access a global 4GL array (array[xxx] of } RECORD) from a C function? } } I have a 4GL program that queries data from a remote SAP system. The } SAP access is presently done through a function in an ESQL/C program } that inserts the data records into an Informix table. When the } function returns successfully, the 4GL program will select these } records into its global array for further processing. Needless to } say, the number of records can vary with every function call. } } I'd like to skip the insert/select part and pass these records } directly back to the 4GL program. Is there a solution? } } I'm working with 4GL 4.10 on SINIX 5.42. As Marco said, one way is to arrange for the ESQL/C code to call an I4GL function which stashes the data in the global array. Alternatively, you can crib the record declaration from the C or ESQL/C file produced by the I4GL compiler, and you can refer to the variable in the ESQL/C code using something like: $extern struct { ... } i4gl_global_array_name[]; You can then process it as if it was an ordinary ESQL/C array or records. Note that this will only work for c-code; with p-code, Marco's suggestion is about the only one which will work. Yours, Jonathan Leffler (johnl@informix.com) #include <witticism.h>