LOCAL
LOCAL var1 [, var2, …, varn]
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
endCode 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