Re: Variables to call...
Posted in 1994
> From: mbehna@promus.com (Michel Behna) > > >> >Hi folks, > >> >I am running 4gl 4.10.UC1 on a Sun and have the following question: > >> >Is there not a method to pass variables to the 4gl 'call' routine or > >> >construct a string that can be run that contains 'call'? > > >You need 4.1, a C compiler, and it only works with RDS. But it does work. > > Not true! You could call a C function and pass it the name of the function ( a > string ) and the parameters and that would work in compiled 4gl as well as in > RDS. RDS does have the disadvantage of needing to recompile the fglgo runner > everytime you want to include a common function into the fglgo runner. Well, I'm not aware of any standard C function that takes a string (char *) and then executes the function named in that string. It's easy to pass a function pointer, and have that executed (in fact that is what the fgl_call routine does when compiled with the 4GL instead of RDS), but that is a compile time binding, not a run time binding. Sounded like this guys wants a run time binding to me. I'd love to see the code that let's you do this is standad C though. C++ can't do it, but Objective-C can (with a method though, not a standard C function). But in Obj-C, almost everything is a runtime binding. > The technique you described should work with the compiled version of 4GL as > well as RDS except you don't access fgl_call. Besides some monster switch/case statement, I don't see how. If you can show me how this works with the C-4GL, I'd like to try it out. It works with the RDS because it sends the function name to the RDS interpreter, which then does an internal lookup and then fires off the p-code runner for that function. RDS does all of the work for us, whereas in the 4GL, the compiler does all of that work before hand and hard codes it into C. There isn't a function dispatcher in a compiled 4GL program. It's just one big nasty piece of C. The only thing inside of a .4ge file is the link entry points for the linker. Now, it wouldn't surpise me if somebody, somewhere has a way of shredding an executable and can figure out from the linking offsets where a function really ended up, page it in, and execute it. But, that's a little deeper than my motivations want to take me, and I don't think Informix has provided it to us. I would also imagine that it may be platform specific. Will (villy@collinscomp.com)