Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

storing function names in variables???

Status
Not open for further replies.

theemperor

Programmer
May 22, 2001
28
AT
Hi all,

does anyone know if it is possible to store function names in variables so that they are not called immediately? Something like this

dim FunctionContainer, testVar

Code:
function foo()
   foo = 10
end function

FunctionContainer = foo

testVar = FunctionContainer()

Regards,
Robert

 
It's quite complicated to explain why I need it. Basically, I have to give the customer the possibility to run his own functions and the solution should be quite generic. I found a way with using the execute-statement!

Robert
 
You can use either the Execute or Eval statement, depending on how you want to do the assignment.

dim FunctionContainer, testVar

FunctionContainer = "foo()"
testVar = Eval(FunctionContainer)
WScript.Echo testvar

testvar=""
FunctionContainer = "testvar = foo()"
Execute FunctionContainer
WScript.Echo testvar
WScript.Quit

function foo()
foo = 10
end function Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top