Author Topic: Calling functions and subs implicity  (Read 10258 times)

support

  • Administrator
  • *****
  • Posts: 859
    • Script BASIC Open Source Project
Calling functions and subs implicity
« 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>
Script BASIC Project Manager