Array Question....please help


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    2

    Default Array Question....please help

    Hi guys,

    I have a problem that I am stuck at for hours. Here is some of my code:

    temparray var word[3]
    temparray.lowbyte[0]=%11100011
    temparray.highbyte[0]=%00011100
    lcdout $fe,$cf,"reis: ",ibin16 temparray[0]
    pause 10000


    The above works great, on my LCD I get 0001110011100011
    but then, as my code progresses,

    temparray.lowbyte[1] =%01010101
    temparray.highbyte[1]=%11111111
    lcdout $fe,$cf,"done: ",ibin16 temparray[0]


    Now when my LCD changes, it displays 0101010111100011
    My question is why does highbyte in array [0] get overwritten with the lowbyte from array[1]. I was expecting to get the first answer since I only changed temparray[1].

    Can somebody please explain why this happened?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Don't you think


    "temparray.highbyte[0]" and "temparray.lowbyte[1]" are one and same memory location ???

    did you try

    Code:
    temparray.lowbyte[2] =%01010101
    temparray.highbyte[2]=%11111111
    lcdout $fe,$cf,"done: ",ibin16 temparray[1]
    instead ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Oct 2009
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Thank you all for your help and for the link.
    I was coming to the conclusion that user Acetronics mentioned but I just wasn't sure why. I'll follow the link above and get some info on word arrays.

    Thank you Gentlemen for all your help.

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  3. Array Question:
    By Archangel in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 28th May 2008, 21:47
  4. How to saparate variable to array and GLCD Question
    By pramarn in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 4th October 2006, 03:42
  5. Stupid array question
    By RUBiksCUbe in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 4th September 2006, 16:03

Members who have read this thread : 0

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