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 | LOCAL

Edit History

LOCAL

LOCAL var1 [, var2, …, varn]

Home > Reference > Language

Declare local variables inside a SUB or FUNC. Local variables are independent of global variables of the same name.

If inside a sub or a function a local variable with the same name as an already existing global variabale is declared, the global variable can’t be accessed inside that function or sub. Changing the local varibale will not change the global variable.

Local variables no longer exist once the SUB or FUNC has returned.

Use local variables insides subs or functions to make sure, that global variables with the same names are not accidentally changed.

Example:

A = 1   ' global variable

print "Global variable before sub: A="; A
MySub()
print "Global variable after sub : A="; A

sub MySub()
    local A    ' Comment this line to see the effect of a local variable
    A = 2
    print "Local variable inside sub : A="; A
end
Code samples using LOCAL
100lines.bas   2048.bas   agendus.bas   analog clock.bas   anomail.bas   Another center finder.bas   another look at trig functions.bas   autumn scene.bas   B+B.bas   bairstow.bas   Ball.bas   balls.bas   base64.bas   bb2fork smurf.bas   bezier's autograph book.bas   bezierbounce.bas   biorythms.bas   bomb.bas   bopit.bas   bowling7.bas   btn 21.bas   bubbles and triangles.bas   calc.bas   Charmap.bas   Charts.bas   checkers.bas   chess.bas   circ.bas   circumscribe triangle.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, 30 May 2023 14:39:39 +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.