ScriptBasic > Tutorials

Calling functions and subs implicity

(1/1)

Support:
SB allows you to pass addresses of functions/subs to other functions and call them implicitly within the function with ICALL.


--- Code: ---FUNCTION addone(x)
  addone = x + 1
END FUNCTION

FUNCTION x10(y)
  x10 = y * 10
END FUNCTION

FUNCTION printit(v,a)
  LOCAL r
  r = ICALL(a,v)
  PRINT r,"\n"
END FUNCTION

f1 = ADDRESS(addone())
f2 = ADDRESS(x10())

printit(1,f1)
printit(1,f2)

--- End code ---

C:\scriptbasic\test>icall
2
10

C:\scriptbasic\test>

Navigation

[0] Message Index

Go to full version