Re: Functions using variables values
Posted in 1997
Topics: Performance & Tuning, Connectivity: ESQL/C, 4GL & Embedded SQL
Adalberto, Here is the header comment for a C module we use. The code is proprietary so I won't include it. It is my understanding that the Informix 4GL Interactive Debugger does something similar to this in order to run C functions. Also, I did not write this, so I would not be much use in answering any questions. A warning: supporting this function is a lot of work. We create load map files after the application is compiled and we do internal caching of values. Without the caching and preprocessing, the performance hit is unacceptable. Also, implementing this function removed our ability to use the 4GL Interactive Debugger. The environment this is implemented in is: SCO Unix 3.2.4.2 using Informix 4GL 4.1. Darryl Peterson darrylap@ix.netcom.com /* "call_function_lu()" calls a 4GL function, given the name of the function. * We assume we're being called from Informix-4GL. We'll use this function * to do "callbacks" in our UI "gizmos". This is completely spiffy. * * Since 4GL passes its arguments and return values on its own explicit * stack, this allows the caller to pass arguments to the function, and * allows the function to return values to the caller. The 4GL calling * convention (from our perspective) looks like this: Parameters are * "push"ed onto the (4GL) stack, using the functions "pushquote," "pushint," * etc. Then the function is called, with a single "normal" parameter: the * number of things that are waiting for it on the (4GL) stack. When it * enters the function, the function uses "popquote," "popint," and the like * to retrieve the 4GL parameters, in reverse order. When it returns, * it uses the functions "retint," "retquote," and others to place the return * value(s) on the stack (in "forward" order) and actually returns an int * indicating the number of things it just "returned" on the stack. * * Is this cool, or what? * * "call_function_lu" takes an arbitrary number of 4GL parameters, and * manipulates the 4GL parameter stack minimally, so as to not have to handle * any parameters except the function name and number of expected return * values. These two values are just popped off the 4GL parameter stack, * leaving the rest of the stack undisturbed. * The first time you call it, it gets the list of functions and addresses * in the (curent) module (executable), which takes a second or two. If you * like, you can call it without any arguments and it will just initialize * the list without doing anything else. * * In Rev. 1.1 this is enhanced by using a cache file for the "nm" output, * specifically the file "$DEFDIR/nm/`basename $0`.nm". For example, in * the test system, the cache for "myscreen.4ge" would be in the path * "/.../nm/myscreen.4ge.nm". If there is any problem * reading the cache file, it just logs an error, runs "nm," and makes the * user wait. * * 4GL modules typically contain about 550 functions before you count any * application functions. Just for a jolly, we also use a hash table * to accelerate the search (hash by first letter of function name). * This is especially easy since "nm" sorts by symbolic name already. * * This is built to use GNU "nm"; any other version will take some tweaking. * Specifically, this assumes: (1) the output is sorted by symbolic name, * (2) the addresses are in hex (lower-case) and start at the first column, * (3) the symbolic name is the last thing on the line, (4) GNU's "nm" places * a "T" in the 10th column of each line describing a function. We ignore * all functions beginning with an underscore ("_"), which is about half. * * Sample GNU "nm" output: * * 00028300 t xamfmt * 0040484c d ypos * 0001c924 T zap */ This is the C function definition: int call_function_lu(int num_args) The is the call that actual calls the function: act_num_ret = (*(func_list[i].func_ptr))(num_args); =========================================================================== On 16 Apr 1997 01:38:34 -0400, adaltam@hotmail.com ("ADALBERTO ALTAMIRANO") wrote: >Hi everybody!! > > My question is in regard to the use of functions, specially in running any >function by using variables values; for example : > > > FUNCTION name_function() > LET var_name = "action" > CALL var_name > > Well, that's the main idea. > Does anybody have any algorithm to this situation or another idea > to find out my problem ? > > > Thanks. > > adaltam@hotmail.com > > >--------------------------------------------------------- >Get Your *Web-Based* Free Email at http://www.hotmail.com >---------------------------------------------------------