FYI - How to Access individual bytes in Word Arrays


Closed Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2003
    Posts
    2,358

    Lightbulb FYI - How to Access individual bytes in Word Arrays

    We all know that we can access the highbyte and lowbyte of a word like so...

    mybyte=myword.highbyte
    mybyte=myword.lowbyte

    it is not too obvious how to achieve this when myword is an array... consider...

    myword var word (10)

    executing the statement...

    mybyte=myword.highbyte(5)

    you would think would return the highbyte of myword(5) in the array, but not so...

    The relationship actually is...

    myword.highbyte(x*2) = the highbyte of myword(x)
    myword.lowbyte(x*2) = the lowbyte of myword(x)

    So the answer to accessing the highbyte of myword(5) in an array using the highbyte (or lowbyte) expression is actually...

    mybyte=myword.highbyte(10)

    As an afterthought (as my explaination confused one person and it tests editing threads as well) it should be considered that when accessing word arrays using highbyte and lowbyte, your array access changes from word to BYTE, that's why you have to skip every other byte.

    Melanie
    Last edited by Melanie; - 21st July 2003 at 09:28.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 08:55
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 02:51
  3. Minimizing code space
    By Tobias in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th May 2009, 08:25
  4. DS2760 Thermocouple Kit from Parallax in PicBasicPro
    By seanharmon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th July 2008, 00:19
  5. calculation problem
    By nicolelawsc in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 31st March 2006, 16:23

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts