CALL
CALL (p [, var1 [, …, varN])
Invoke a sub or func by address pointer p
. Optional
var1
to varN
variables of every SmallBASIC
data type can be passed to function or sub, the address pointer points
to.
Example 1: CALL with a subroutine pointer
sub MyPrint(i)
print i
end
a = @MyPrintcall a, "test" ' when using CALL for subroutines,
' please use CALL without brakets
Example 2: CALL with a function pointer
func Increment(i, b)
return i + b
end
1
x =
a = @Incrementcall(a,x,2) ' when using CALL for functions,
y = ' please use CALL with brakets
print y
Example 3: CALL with a subroutine pointer and BYREF:
sub Increment(byref i, b)
i = i + bend
1
x =
a = @Incrementcall a,x,2
print x
Example 4: Passing function pointer to a function
func Increment(i)
return i + 1
end
func Decrement(i)
return i - 1
end
func MyFunc(f, i)
return call(f,i)
end
a = @Increment
b = @Decrement2
x = print x
x = MyFunc(a,x): print x x = MyFunc(b,x):
Code samples using CALL
000 hello.bas
001 3 ways to print hello 5 times.bas
002 numeric variables.bas
003 conditional branching.bas
004 loops.bas
005 challenge.bas
006 arrays+.bas
Balleta 2-11-15.bas
bezier_pen.bas
bopit.bas
btn 21.bas
checkers.bas
checkers.bas
chess.bas
chess.bas
dogstar5.bas
draw rectangle.bas
fireworks.bas
fizzle2.bas
form demo.bas
g2 Life.bas
g3 Life.bas
g4 Life.bas
g5 Life.bas
g6 Life.bas
hangman v2.bas
hangman.bas
image demo.bas
matrix_solve.bas
Language
AND
AS
BAND
BG
BOR
BYREF
CALL
CASE
CATCH
CONST
DECLARE
DEF
DO
ELIF
ELSE
ELSEIF
END
END TRY
ENDIF
EQV
EXIT
FALSE
FI
FOR
FUNC
GOSUB
GOTO
IF
IFF
IMP
IN
LABEL
LET
LIKE
LOCAL
LSHIFT
MDL
MOD
NAND
NEXT
NOR
NOT
ON
OR
REM
REPEAT
RETURN
RSHIFT
SELECT
STEP
STOP
SUB
THEN
THROW
TO
TRUE
TRY
UNTIL
USE
USG
USING
WEND
WHILE
XNOR
XOR
If there is insufficient information on this page and you wish learn more about CALL,
please send an email to smallbasic@gmail.com. You can help to improve information about
CALL by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.