UNIX SYSTEM CALLS FROM 4G
Posted in 1995
A> From: antaya@io.org (J. Cameron Antaya) > Subject: UNIX system calls from 4GL A> Somebody wanted to know if they could do UNIX system call from 4GL without > going through 'C'. > The following is code I use to do this: A> DEFINE RunString CHAR(40) A> LET RunString = "fglgo diskprog.4gi" > RUN RunString A> The only thing I still haven't been able to accomplish is having the program > return a variable back to the program, other than load the value to a table. OK, here's the lowdown on executing a subshell process from 4gl: 1. Do as above. This is best if you want to put a variable into the Runstring. 2. simply: RUN "whatever literal text you want to put in a string" 3. RUN RunString RETURNING return_val LET return_val = return_val / 256 Now you can IF/THEN or CASE return_val based on the expected return code 4. If you have a C compiler, then you can make a C function to run a system call, with the added benefit that you can change STTY settings to prevent the screen clearing/redrawing thing that Informix does when using the RUN command. This requires all that popping and returning you need to do to interface a C function with 4gl. Also, either you would always have to return something, or you have two separate c functions, one that returns a exit value, another that doesn't. Finally, note that all options are available to either C-code or P-code versions. The last option, of course requires a C compiler, and, if using P-code, making a custom runner. I can post those c functions, but I think someone else mentioned a while back that there are some available anonymous ftp (somewhere). Tim --- ~ SPEED 1.40 [NR] ~