CHANGING THE ENV
Posted in 1995
> From: Robert Minter <rob@dssmktg.com>
R> For all who are curious, how do you alter the environment while running
> a 4gl program? I've tried this:
R> MAIN
> DEFINE arg_str CHAR(20)
> LET arg_str = fgl_getenv("ROBS_ENV")
> DISPLAY "arg_str = ", arg_str CLIPPED
> RUN "ROBS_ENV=hello ; export ROBS_ENV"
> LET arg_str = fgl_getenv("ROBS_ENV")
> DISPLAY "arg_str = ", arg_str CLIPPED
> END MAIN
R> and both displays are blank. Any clues?
IF ROBS_ENV was not set before entering the Informix program, it will be
blank after the first let statement. If it did have a value, it should not
be blank. The run statement does a nice job of setting ROBS_ENV for the
subshell that Informix spawns. However, shell does not export the value of
^^^^^^^^ the environment variable to the parent shell that spawned it.
That's why no matter what ROBS_ENV was before the RUN statement, it will
not change after the second LET statement.
I thought I remembered reading (in Tech Notes, perhaps?) that Informix
identified that there is no INFORMIX way of changing environment variables,
only getting their values.
BTW, I tested the following code in both C and P-code versions of 4gl
(5.xx NCR UNIX) on our box:
$ echo $PROJECTDIR
/usr/project
test.4gl:
main
define env_var char (40)
let env_var = fgl_getenv("PROJECTDIR")
display env_var at 2,1
end main
output:
/usr/project
in both flavors of 4gl.
Tim
---
~ SPEED 1.40 [NR] ~