Array Indexing


Closed Thread
Results 1 to 2 of 2

Thread: Array Indexing

  1. #1
    Join Date
    Jul 2003
    Location
    Lancashire
    Posts
    50

    Default Array Indexing

    Hi All

    I`m have a feeling this can`t be done unless I`ve missed something. I have a bit array containing 16 values of which some I want and some I dont. lets say for now that first 6 are valid, the next two are not, the next 6 are valid for example.
    I send these to an LCD using str Values\6. Now the question, is it possible to start again from str Values\8 up to str Values\14 ?. The only way I have thought of so far is to do the second part as a for next loop starting at 8. Is there an easier way here I`ve missed ?.

    Cheers Pete

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by enigma View Post
    Hi All

    I`m have a feeling this can`t be done unless I`ve missed something. I have a bit array containing 16 values of which some I want and some I dont. lets say for now that first 6 are valid, the next two are not, the next 6 are valid for example.
    I send these to an LCD using str Values\6. Now the question, is it possible to start again from str Values\8 up to str Values\14 ?. The only way I have thought of so far is to do the second part as a for next loop starting at 8. Is there an easier way here I`ve missed ?.

    Cheers Pete

    How about copying the bit array to a temp variable, isolate the unused bits out, shift the upper bits down a couple, then recombining the result back into the original?
    For instance, 16 bit array in a word, like you said, 1st 6 good, next 2 bad, next 6 good, last 2 bad...

    temp1 var word 'original bit array
    temp2 var word 'temp bit array

    temp2 = temp1 'copy to temp
    temp2 = temp2 & %1111110000000000 'isolate upper 6 using AND function
    temp1 = temp1 & %0000000000111111 'isolate lower 6 using AND function

    temp2 = temp2 >> 4 'shift upper 6 bits down by 4 bits
    temp1 = temp1 | temp2 'recombine the 2 using OR function

    then spit them out the LCD as you described earlier...

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 values changing
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th October 2009, 23:13
  4. Indexer not indexing...a basic PBP problem??
    By jellis00 in forum General
    Replies: 8
    Last Post: - 24th March 2009, 16:53
  5. RS232 receive an array (packet)
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th February 2008, 05:02

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