GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | CALL

Edit History

CALL

CALL (p [, var1 [, …, varN])

Home > Reference > Language

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 = @MyPrint
call 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

x = 1
a = @Increment
y = call(a,x,2)     ' when using CALL for functions,
                    ' please use CALL with brakets
print y

Example 3: CALL with a subroutine pointer and BYREF:

sub Increment(byref i, b)
  i = i + b
end

x = 1
a = @Increment
call 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 = @Decrement
x = 2
x = MyFunc(a,x): print x
x = MyFunc(b,x): print 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   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   memory match game.bas   pirate.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  
This page was last edited on Tue, 19 Sep 2023 14:53:45 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.