HSERIN string starting index ?


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103


    Did you find this post helpful? Yes | No

    Default Re: HSERIN string starting index ?

    Hello Henrik I really can't figure out if it is working or not , so I can't say a certain thing about that because sometimes it seems working as it should and sometimes it doesn't .. I'm really not sure , that's why it a complex situation .. I need to observe and make other tests even need to modify my code to understand if it is properly working(I'm speaking for my code and by the way I could have tested it with a simple simulation code yet I haven't done so far because of being busy with a very long code my mind is like a trash )
    - Ipsa scientia potestas est -

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: HSERIN string starting index ?

    Tried the following code:
    Code:
    i       VAR BYTE
    Array   VAR BYTE[128]
    
    PAUSE 3000
    
    Main:
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 0, don't use '0'", 13]
      HSERIN[STR Array\6]
      GOSUB Echo
      
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 12, don't use '0'", 13]
      HSERIN[STR Array[12]\6]
      GOSUB Echo
      
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 3, don't use '0'", 13]
      HSERIN[STR Array[3]\6]
      GOSUB Echo
      
      GOSUB ClearArray
      HSEROUT["Send 6 bytes, these should end up starting at index 21, don't use '0'", 13]
      HSERIN[STR Array[21]\6]
      GOSUB Echo
      
      Goto Main
    
    Echo:
    For i = 0 to 31
        HSEROUT[Array[i], " "]
    NEXT
    HSEROUT[13,13]
    RETURN
    
    ClearArray:
        For i = 0 to 31
            Array[i] = "0"
        NEXT
    RETURN
    And, sending the string "123456" it gives the following results:
    Code:
    Send 6 bytes, these should end up starting at index 0, don't use '0'
    1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    
    Send 6 bytes, these should end up starting at index 12, don't use '0'
    0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    
    Send 6 bytes, these should end up starting at index 3, don't use '0'
    0 0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
    
    Send 6 bytes, these should end up starting at index 21, don't use '0'
    0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 5 6 0 0 0 0 0
    Seems to work exactly as expected. One thing you need to watch out for is to not write outside of the array since that will corrupt the variable(s) being stored there - but that's not specific to this method.

    /Henrik.

Similar Threads

  1. Hserin parsing string...again?
    By kevlar129bp in forum Serial
    Replies: 21
    Last Post: - 9th July 2012, 16:35
  2. HSERIN for variable length string
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th February 2010, 05:58
  3. How to index Port variable
    By jpadin1 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th February 2010, 10:36
  4. How to convert a HSERIN string to a hex value?
    By ShortBus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd October 2009, 04:41
  5. parsing string from hserin
    By xxxxxx in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 2nd April 2009, 18:42

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