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

Support

  • Administrator
  • *****
  • Posts: 1
    • View Profile
Calling functions and subs implicity
« on: October 08, 2009, 05:51:58 pm »
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>