PDA

View Full Version : Variable variables.



Hugh
12-20-2009, 03:56 AM
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

Phil Pilgrim (PhiPi)
12-20-2009, 04:08 AM
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

heater
12-20-2009, 04:17 AM
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 Green
12-20-2009, 04:17 AM
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.

StefanL38
12-20-2009, 01:51 PM
First lesson:

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

best regards

Stefan

localroger
12-20-2009, 11:40 PM
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.

Hugh
12-21-2009, 12:45 AM
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.

StefanL38
12-21-2009, 01:00 AM
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 Green
12-21-2009, 01:06 AM
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.