Jon-Huhn
05-06-2009, 01:43 PM
Without using the execute() command, I'm trying to build a function that will accept as arguments an object, the name of a function in that object, and any arguments needed for that function, and then run that function.
For example, the following snippet will do as described above (assuming no more than 3 arguments are given for the function):
fn run object funcName argArray = (local cachedFunc=getProperty object funcName
if argArray.count==0 then cachedFunc()
else if argArray.count==1 then cachedFunc argArray[1]
else if argArray.count==2 then cachedFunc argArray[1] argArray[2]
else if argArray.count==3 then cachedFunc argArray[1] argArray[2] argArray[3]
)
Now, my problem is that I need this to be able to support optional parameter keywords as well, and I can't figure out how to do it without breaking down and using exectute(), which is about 15 times slower (and therefore unacceptable for what I need).
Any ideas? Thanks!
For example, the following snippet will do as described above (assuming no more than 3 arguments are given for the function):
fn run object funcName argArray = (local cachedFunc=getProperty object funcName
if argArray.count==0 then cachedFunc()
else if argArray.count==1 then cachedFunc argArray[1]
else if argArray.count==2 then cachedFunc argArray[1] argArray[2]
else if argArray.count==3 then cachedFunc argArray[1] argArray[2] argArray[3]
)
Now, my problem is that I need this to be able to support optional parameter keywords as well, and I can't figure out how to do it without breaking down and using exectute(), which is about 15 times slower (and therefore unacceptable for what I need).
Any ideas? Thanks!
