t(fxx,xx)
Prgm
local xval,result
⁻10→xval
expr(fxx&"|"&xx&"="&string(xval))→result
EndPrgm
Usually the function must be evaluated several times, and there is no need to build the entire string
expression each time. Avoid this by saving most of the expression as a local variable:
t(fxx,xx)
Prgm
local xval,result,fstring
fxx&"|"&xx&"="→fstring
10→xval
expr(fstring&string(xval))→result
EndPrgm
Most of the string is saved in local variable fstring, which is then used in expr().
t() can be be a function or a program.
Using indirection
Instead of using expr(), you can use indirection. The function name must still be passed as a string, but
the parameters can be passed as simple expressions. For example, suppose we have a function t3()
that we want to evaluate from function t1(). t3() looks like this:
t3(xx1,xx2)
Func
if xx1<0 then
return ⁻1
else
return xx1*xx2
endif
EndFunc
This is the calling routine routine t1():
t1(fname,x1,x2)
Func
#fname(x1,x2)
EndFunc
Then, to run t1() with function t3(), use this call:
t1("t3",2,3)
which returns 6.
7 - 22