Re: UNIX SYSTEM CALLS FROM 4G
Posted in 1995
Just a warning on return values: We're using compiled 4GL Version 4.11.UC3 on Solaris. If your program runs without problems, but does not end with an EXIT PROGRAM statement, ie. (EXIT PROGRAM 0, or EXIT PROGRAM 5), the return code will be the number of parameters on the command line. For example: Command Line Return value if no EXIT PROGRAM specified -------------------------- ----------------------------------------- myprog.4ge 1 myprog.4ge abc def 3 I've been told that it's a known bug on *some* systems. So, the point is if you rely on return codes, don't assume your program will exit with 0 when you hit the END MAIN statement. Code for an EXIT PROGRAM 0. -Joel Schumacher JCPenney Co. 12700 Park Central Pl. M/S 6019 Dallas, TX 75251 jschumac@uns-dv1.jcpenney.com OR jschumac@jcpenney.com Timothy Hood (timothy.hood@sltrib.com) wrote: : 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] ~ -- -Joel Schumacher jschumac@uns-dv1.jcpenney.com OR jschumac@jcpenney.com