ScriptBasic

ScriptBasic => Tutorials => Topic started by: Support on October 08, 2009, 10:51:58 AM

Title: Calling functions and subs implicity
Post by: Support on October 08, 2009, 10:51:58 AM
SB allows you to pass addresses of functions/subs to other functions and call them implicitly within the function with ICALL.

Code: [Select]
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)

C:\scriptbasic\test>icall
2
10

C:\scriptbasic\test>