Hi,

first, sorry for my english \:\)
i recently discovered a problem with environment var.
Look at the following code
 Code:
$path = "c:\rep1;c:\;"+%path%
SETL "PATH="+$path
SHELL 'cmd /c start "rep1" path'

$path = "c:\rep2;c:\;"+%path%
SETL "PATH="+$path
SHELL 'cmd /c start "rep2" path'

In the first console, path is c:\rep1;c:\;...
In the second console, path is c:\rep2;c:\;...
There is no reference to c:\rep1.

According to kix help, this is normal because setl doesn't change environment var for current process. I suppose SETL use an internal array to save modifications and this array is used before call to SHELL or RUN to create the new environment block for sub-process.

In the script, a solution could be
 Code:
$path = "c:\rep1;c:\;"+%path%
SETL "PATH="+$path
SHELL 'cmd /c start "rep1" path'

$path = "c:\rep2;"+$path
SETL "PATH="+$path
SHELL 'cmd /c start "rep2" path'


Now, real scripts are not as simples.
We have scripts to launch applications. theses scripts use generic functions to configure global modules like oracle client or java and specific functions to configure the application to launch. It seems very difficult to use global variables :
 Code:
;-- configure generic modules --
$=ConfigureOracle11()
$=ConfigureJava16()

;-- configure application --
set path="d:\appl\winapp32\my appli dir;"+%path%

SHELL "d:\appl\winapp32\my appli dir\my appli.exe;"

exit

function ConfigureOracle11()
  SETL PATH="c:\program files\oracle11\bin;"+%path%
endfunction

function ConfigureJava16()
  SETL PATH="c:\program files\java\jre\bin;"+%path%
endfunction


In this case, we lost reference to oracle 11 and java path in the resultant path.
Has somebody already seen this problem and found an elegant solution ?

I think an elegant solution could be a modification of ExpandEnvironmentVars function to add an optional parameter to get modifications made with setl or a new function GetL.
The sample script would become :
 Code:
SETL "PATH="+ExpandEnvironmentVars( "c:\rep1;c:\;"+%path%, 1 )
SHELL 'cmd /c start "rep1" path'

SETL "PATH="+ExpandEnvironmentVars( "c:\rep2;"+%path%, 1 )
SHELL 'cmd /c start "rep2" path'

or
 Code:
SETL "PATH="+"c:\rep1;c:\;"+GetL( "PATH" )
SHELL 'cmd /c start "rep1" path'

SETL "PATH="+"c:\rep2;"+GetL( "PATH" )
SHELL 'cmd /c start "rep2" path'


A suggestion for ruud ???

PS : i have the same problem of environment vars with a function i wrote to launch program with WMI. I have no acces to vars modified with setl and process launched via WMI do not see modified vars !!!
_________________________
Christophe