Is there a better way to do this?... strings of letters


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Is there a better way to do this?... strings of letters

    Hi,
    You could use ArrayWrite and a pointer into that array, something like
    Code:
    Msg VAR BYTE[32]      '32 byte array for displayed message, zero-indexed
    MsgPointer VAR BYTE
    
    ArrayWrite Message, ["Honor",13]   'You can use 13 (or something else) as the end of message character to avoid having to count characters.
    GOSUB DisplayMsg
    ArrayWrite Message, ["This is the second message",13]
    GOSUB DisplayMsg
    
    END
    
    DisplayMsg:
      MsgPointer = 0 : Char = 0
    
      While Char <> 13
         Char = Msg[MsgPointer]
         'Do your display magic here or GOSUB it.
         MsgPointer = MsgPointer + 1
      Wend 
    
    RETURN
    This caught my eye:
    Code:
    lookup r, [1,2,4,16,16,32,64,128], row   'creates walking "1" for row scanning
    Well, that's one idea...

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Is there a better way to do this?... strings of letters

    Thanks Henrik,

    I have used your suggestion... Program is working good.

    Good catch on the duplicated "16". (it is correct in my case, though)

    I am always amazed at how one can look at someone elses code and follow it through with logic. The person writing the code uaually has "eat,slept and breathed" their code as they write and debug it. But the person trying to help is looking at the code for the first time, cold.

    The reason I skip 8 and have 16 twice in the lookup is because PortA.3 is an input only pin. So I am using bit A.4 then B.4 next. So I just write the walking bit to the A port for the first 4 postions, then the B port for the next four.

    Code:
    lookup r, [1,2,4,16,16,32,64,128], row  'creates walking "1" for row scanning
                if r<4 then 
                PortA=row          'PortA 0,1,2,4 is connected to row 1-4 
                Else 
                PortB=row          'PortB 4,5,6,7 is connected to row 5-8
                endif
    Thanks for your help
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

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