New Mexico Mark posted some interesting code in the ScheduleTask UDF thread.. I tried the concept in a new project and it's pretty cool. I thought I'd post an example here so it isn't buried in post 27 or so.

Basically, it allows you to pass the NAME of a variable to a function. The function can then convert the name to a variable and make a local copy. By adding a line of code that reverses the process, when the function exits, it copies its local copy back to the original.

Not quite as elegant as indirection, but useful nonetheless.

Glenn

code:
 
; example - red fish in, blue fish out
; Define simple array
$Seuss = "Red", "Fish"

; Display contents
"Seuss before fn: " + $Seuss[0] + " " + $Seuss[1] ?

; call the function, passing the NAME of the var
; note simple text string, no leading "$"
fn("Seuss")

; display contents after return from function
"Seuss after fn: " + $Seuss[0] + " " + $Seuss[1] ?


Function fn($ArgName)
; $ArgName contains the name of an external variable

; convert the arg name to an arg reference ("var" becomes "$var")
; remember that "$$" in a string becomes a single "$" when evaluated
; thus, the Execute "sees" ($Arg = $Seuss)
$RC = Execute('$$Arg="$$"+$ArgName')

; copy the received var to a local var
$RC = Execute('$$fArg=$Arg')

; display the contents of the local variable
"fn received: " + $fArg[0] + " " + $fArg[1] ?

; modify the local variable
$fArg[0] = "Blue"

; show the contents of the modified local var
"modified, fn contains: " + $fArg[0] + " " + $fArg[1] ?

; copy local var back to original
$RC = Execute('$Arg=$$fArg')

EndFunction

_________________________
Actually I am a Rocket Scientist! \:D