thanks guys ,
i lost a lot a time finding out the hardway ,
fortunatly the the indexed arrays i have so far are byte only
except for 2 which are word , and only this one had used the myvarable.highbyte to try get data , which need to be changed
looking at Melanie example ( thanks for the link hendrick )
5. How can I reference a BYTE in a WORD ARRAY?
As can be previously seen, all the bits in an array are stored sequentially in memory. It follows that the BYTES in a WORD ARRAY also follow sequentially. This means we can easily extract any BYTE we want to out of a WORD Array in a similar manner. Consider again…
MyWordArray var WORD [25]
There are actually 50 Bytes in this array (0-49). The first byte (0) being the LOWBYTE of MywordArray(0), and the last byte (49) being the HIGHBYTE of MyWordArray(24). Using a similar manner to Bit access, we can access all fifty Bytes of this Word array like so…
MyWordArray.Lowbyte(MyVar)
Where MyVar is in the range 0-49 for my previously defined example Array of 25 Words.
This is really handy, because we can use this method of loading or unloading Word Arrays from EEPROM for example very easily.
Note that HIGHBYTE cannot be used in this instance, because it cannot access the LowByte of the first array element… ie..
MyWordArray.HighByte(0)=MywordArray.LowByte(1)
all the way to…
MyWordArray.HighByte(48)=MywordArray.LowByte(49)
More dangerously, MyWordArray.HighByte(49) will actually perform an unauthorised access on an unknown byte OUTSIDE the MyWordArray structure.
Melanie
Bookmarks