I stumbled upon this...first the code
code:
$a = "test"
$string = "this is a string with ~$$a~ in it"
; this is just filler to get to the function....
;
if instr($string,"~") <> 0
? FillVariable($string)
else
? $String
endif
exit
; This is a function that will look for $variables inside a
; string, and fill them with their values, for the moment, I
; am just trying to fill the variable.
Function FillVariable($string)
DIM $string, $element ;<---this line is playing a major part in the weirdness!
$string = split($string,"~")
for each $element in $string
if substr($element,1,1) = "$"
$nul = execute('$$trap = $element ? "in execute $$$$trap = $$trap"')
? "Outside of execute $$trap = " + $trap
endif
next
endfunction
Everything is working fine with the above code... but since i want to my variables used inside a function, to stay inside the function. I do a DIM of all of the variables that the function uses.
But if i change this line
code:
DIM $string, $element ;<---this line is playing a major part in the weirdness!
to this
code:
DIM $string, $element, $trap ;<---this line is playing a major part in the weirdness!
the variable $trap never makes it out of the EXECUTE() command.
[edit]
It appears that any variable defined in an execute() command is defined as a global variable. Shouldn't variables restricted to a subroutine with a DIM command stay with in that subroutine? This is why when i DIM $trap inside the function, and then i do an EXECUTE() with $trap, $trap new value is set at the GLOBAL level, not at the calling DIMed level (does that make any sense?)
Bryce
------------------
kix.isorg.net
[This message has been edited by Bryce (edited 04 May 2001).]