PDA

View Full Version : Advanced Arrays



GoldStar
- 16th May 2009, 06:43
I'm a bit confused about arrays, I'm trying to initialize an array at runtime from saved EEPROM data, but I don't really understand how to edit what I need.



Users var word[10]


Here is my array of users, but PBP won't let me


Users[10].bit0 = 0 (syntax not supported)

However


Users.bit0 = 0

compiles fine. And


Users.byte3 = 0

does not. Is there any easy way I can access each byte of the Users array within a for loop? If all else fails I could rewrite it using this http://www.picbasic.co.uk/forum/showthread.php?t=2444 but It'd be nice to see what the compiler is up to :)

GoldStar
- 16th May 2009, 06:49
It seems that everything is explained here and google is a much better search engine than vBulletin apparently :)

http://www.picbasic.co.uk/forum/showthread.php?t=544



For i = 0 to 19
read i, Users.Lowbyte(i)
Next i

Compiles without a problem, I'm hoping that this will load the first 20 EEPROM bytes into the 10 words I have, correct?

sinoteq
- 16th May 2009, 06:58
Hi
If you dig deep enough in the FAQ section by selecting "Show all threads from the beginning" you will find a Melanie artwork called Bits, Bytes Words and Arrays. Or you click here http://www.picbasic.co.uk/forum/showthread.php?t=544

This will give you all the answers you'll need for accessing an array and other neat tricks that will come in handy later in life.