Shop OBEX P1 Docs P2 Docs Learn Events
WORD(0).HIGHBYTE = X doesnt work. Not functional for arrays? — Parallax Forums

WORD(0).HIGHBYTE = X doesnt work. Not functional for arrays?

sccoupesccoupe Posts: 118
edited 2011-08-12 08:31 in BASIC Stamp
I need to set highbyte and lowbyte of a word in an array on a BS2 and it doesnt seem to like it.

WORD.HIGHBYTE = X works fine, but

WORD(0).HIGHBYTE = X does not.


I havent been able to to set bits this way in byte arrays either. Am I using ti wrong and can this not be done with arrays?

Thanks

Jason


EDIT: I thought that WORD.HIGHBYTE(0) = X worked, as the compiler didnt complain, but it WORD(0) always = 0 when sent to debug. I did try WORD(0) = 1 and it was actually 1 when sent to debug. Whats going on here?

Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-08-12 08:31
    The subscript has to come last and the order of bytes is LOWBYTE first, then HIGHBYTE, so

    aWord.LOWBYTE(0) is the least significant byte of aWord and aWord.LOWBYTE(1) is the most significant byte of aWord and is the same as aWord.HIGHBYTE

    You can also write aWord.BIT0(n) to access the nth bit of aWord starting at the least significant bit.
Sign In or Register to comment.