Local variables on TI92+


[Prev][Next][Index][Thread]

Local variables on TI92+



I noticed a rather strange behaviour of local variables in
TI92 Basic. I mean strange because being a programmer I have
never encountered something like this before.

Let's assume we have the following program skeleton:

mainprog()
Prgm

  Local avar                @ a variable local to maiprog
  Local subproc             @ a local subroutine

  Define subproc(x) = Prgm  @ here we actually define the
    ... blah... blah...     @  subroutine
    Disp avar               @ we display the variable avar
  EndPrgm

  ... blah... blah ..
EndPrgm


The variable 'avar' used in 'subproc' is NOT the 'avar'
defined in the 'mainprog' - contrary to what you would
expect from a language allowing nested subprogram
definitions!

Correct me if I am mistaken.

Regards
mjw


Follow-Ups: