What would be the easiest way to expand a string that represents parameters to a function? The function, number of parameters, and parameter types are all unknown - but they are all static data (strings and numbers).
Here's an example of what I mean. My strings may look like this:
Code: Select all
myfunc := "CallThis"
myargs := "1,two,three,4,5.0"
I'm currently using
StrSplit(), then returning a closure that calls the function with the exact number of parameters by using a
switch statement (each case of the switch has a different number of parameters). But that solution is pretty ugly, and requires manually expanding the switch to support any specific number of parameters. Is there any quick and easy way to bind this string of parameters to the function call as a closure or bound function?
I tried just expanding the entire string:
return %myfunc%.Bind(%myargs%), but AHK didn't seem to like that very much. I think because it is expanding the string contents into would-be variables instead of data - it doesn't know if my parameters (such as
two and
three) are variables or static strings. They are all static strings, in case that matters.
I appreciate any advice!