| 08-04-2007, 02:11 AM | #1 |
Code:
set Dir[1] = "East"
set Dir[2] = "West"
set Dir[3] = "North"
set Dir[4] = "South"
if i<3 then
set x = ExecuteFunc("dir" + dir[i] + "(" + R2S(x) + ")")
else
set y = ExecuteFunc("dir" + dir[i] + "(" + R2S(y) + ")")
endifCode:
function dirNorth takes real y returns real set y=y+50 return y endfunction function dirSouth takes real y returns real set y=y-50 return y endfunction function dirEast takes real x returns real set x=x+50 return x endfunction function dirWest takes real x returns real set x=x-50 return x endfunction How could I execute a function from a string and save the returned value to a variable? |
| 08-04-2007, 02:13 AM | #2 |
ExecuteFunc() isn't an eval(). It can only call functions of no arguments and no return value. You need to arrange for IO yourself. Typically you do this with global variables. Search the forums for example uses. |
| 08-04-2007, 02:19 AM | #3 |
x.x Was thinking of using global variables next. Thanks again. |
