Shop OBEX P1 Docs P2 Docs Learn Events
"de-allocating" variables during run-time — Parallax Forums

"de-allocating" variables during run-time

davejamesdavejames Posts: 4,047
edited 2012-01-04 07:46 in BASIC Stamp
Hi All,

I'm kinda running out of variables in my BS2-oriented project and am wondering if there is a way to de-allocate a variable used in one portion of the program, and then use the freed space for a variable in another portion of the program?

Did that make sense?

I'm gonna guess "no" as maybe the Tokenizer needs to know about all variables up-front when it does the memory allocation. But, I thought I'd ask.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-01-03 20:03
    You can give the same variable multiple names, for use in different parts of a program, viz:
    Name1   VAR Word
    Name2   VAR Name1
    

    In this case, Name1 and Name2 share the same variable space, since Name2 is an "alias" for Name1. You just have to be careful that both aliases do not require the space at the same time.

    -Phil
  • davejamesdavejames Posts: 4,047
    edited 2012-01-04 07:46
    You can give the same variable multiple names, for used in different parts of a program, viz:
    Name1   VAR Word
    Name2   VAR Name1
    

    In this case, Name1 and Name2 share the same variable space, since Name2 is an "alias" for Name1. You just have to be careful that both aliases do not require the space at the same time.

    -Phil

    AWESOME! That's the ticket. :thumb:

    Caveat noted and understood.

    Thanks Mr. Pilgrim!
Sign In or Register to comment.