Shop OBEX P1 Docs P2 Docs Learn Events
Variable variables. — Parallax Forums

Variable variables.

HughHugh Posts: 362
edited 2009-12-20 18:06 in Propeller 1
I think I must have missed something and/or inadvertantly broken some rule.

I have been pulling my hair out for weeks with some ccde that just doesn't quite work. Noticing that one of the counters in the code wasn't incrementing (whatever I did to it) I moved it from the bottom of the VAR block to the top. Bingo! Everything is hunky-dory again.

F8 showed 254 longs used for variables. Is there a limit, a preference order or any other 'rule' about variables? If there is a limit to memory that can be allocated to variables, why disn't the Prop Tool warn me that I had stepped over a line?

Another lesson learned!

Thanks
Hugh

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hugh - the thinking woman's Geoffrey Pyke.

Post Edited (Hugh) : 12/19/2009 9:07:46 PM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-12-19 21:08
    Hugh,

    From your description, I would guess that there was (and still is) a bug in your program. I would recommend posting your entire program here so we can have a look at it.

    -Phil
  • heaterheater Posts: 3,370
    edited 2009-12-19 21:17
    What lesson learned Huge? I think you stil have an unsolved problem lurking there.

    I've never had a problem with my variables not being variable. Unless I'm trying to access them via some wonky pointer scheme that ends up changing the wrong thing in memory.

    Be aware that Spin puts all the LONGs first in memory then the WORDs then the BYTEs so if you are relying on things being in some order in memory it may not bee what you think.

    So we need to see a bit of your code, quite possibly all, to see what is up.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    For me, the past is not over yet.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-19 21:17
    There's no 'rule' about variables. The only limit to memory usage is that the program, its variables, and whatever stack is needed all need to fit in 32K. Most likely you have an array somewhere and you're accessing it with an invalid subscript, accidentally changing some adjacent variable (or code), then noticing it later in execution.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-20 06:51
    First lesson:

    attach your COMPLETE code to a posting following the way shown in the attached picture

    best regards

    Stefan
  • localrogerlocalroger Posts: 3,452
    edited 2009-12-20 16:40
    You cannot depend on variables being grouped together in VAR block being grouped in the same order in RAM. The Proptool rearranges the variables in order to use the least possible RAM while preserving Long and Word alignment.
  • HughHugh Posts: 362
    edited 2009-12-20 17:45
    Mike Green said...
    Most likely you have an array somewhere and you're accessing it with an invalid subscript, accidentally changing some adjacent variable (or code), then noticing it later in execution.
    As usual, Mike is on the money and I need to eat humble pie. I was one byte out in an array which much have been affecting a contiguous variable. Rather than casting aspersion on all things Prop-shaped, I should have perceived this as indicative of this type of problem.

    I shall go out into the snow and beat myself with birch twigs until I am sufficiently contrite that I am able to visit this forum again. 'Thank you' and 'sorry' in equal measures to you all.

    Hugh

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hugh - the thinking woman's Geoffrey Pyke.
  • StefanL38StefanL38 Posts: 2,292
    edited 2009-12-20 18:00
    Hello Hugh,

    throughout the year be friendly to yourself and patient with yourself

    Today be very friendly to yourself and very patient with yourself: it's christmas time !

    best wishes

    Stefan
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-20 18:06
    A sauna followed by a quick run through the snow (with good mukluks) and a little more sauna would be a better. The birch twigs are best used in the sauna itself.
Sign In or Register to comment.