Changing the ENV
Posted in 1995
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
> How do you alter the environment while running a 4gl program? Try this. ############################ # 4GL filename: testprog.4gl globals define unixlpdest char(80) end globals main define flen integer, fenv char(80), freturn integer let fenv="LPDEST="clipped,"lp_daisy"clipped # "lp_daisy" = new value for LPDEST. Good for life of this program. let flen=length(fenv) + 1 call chglpdest(fenv,flen) returning freturn run "lp ./testprog.4gl" # test by printing file to default printer end main ############################ /* C function called by 4gl program to set env value Filename: chglpdest.c */ #include <stdio.h> extern char unixlpdest[80]; int chglpdest(nargs) int nargs; { int vlen; int retcode=1; int p_rep; if(nargs == 2){ popint(&vlen); popquote(unixlpdest,vlen); if((p_rep=putenv(unixlpdest)) == 0) retcode=0; } retint(retcode); return(1); } ############################ // script to compile 4gl and c program c4gl testprog.4gl chglpdest.c -o testprog.4ge ############################