Assigning a string variable to another string variable


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425

    Default Assigning a string variable to another string variable

    I'm so close I can smell it.

    I'm using this to get my data:
    Code:
    DAT VAR byte[255]
    UNIT1 VAR byte[255]
    UNIT2 VAR byte[255]
    UNIT3 VAR byte[255]
    CMD VAR BYTE
    
    HSERIN 1, COMPLETE_RX_TRANSFER,[wait ("&"),dec2 CMD, STR DAT\255\"#"]

    This works well. The problem is, I want to filter the DAT data and then assign different string variables for the DAT. It looks like this:
    Code:
    SELECT CASE CMD
        CASE 80 
            UNIT1=DAT
            
        CASE 81 
            UNIT2=DAT
        CASE 83 
            UNIT3=DAT
    END SELECT

    The problem is that when I go to display the newly assigned variables I only get the first character. I've tried UNIT1=DAT\255 and that returns an error. What am I missing? I know I can just filter it with HSERIN but I thought it would make the program quicker if I used one HSERIN statement and then used select case to sort the data.

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


    Did you find this post helpful? Yes | No

    Default Re: Assigning a string variable to another string variable

    Hi,
    I don't quite understand why you need to do what you're trying to do, it seems like a waste of RAM to have multiple copies of the same data instead of just acting on the data stored in the DAT array. But anyway, one way would be like
    Code:
    i VAR BYTE
    For i = 0 to 254
       UNIT1[i] = DAT[i]
    NEXT
    /Henrik.

  3. #3
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    425


    Did you find this post helpful? Yes | No

    Default Re: Assigning a string variable to another string variable

    I'm not quite sure what I'm doing but your technique worked well.

    Thanks.

Similar Threads

  1. Multi-digit word variable to string
    By Amoque in forum mel PIC BASIC Pro
    Replies: 43
    Last Post: - 21st December 2021, 11:55
  2. Transform String Variable
    By Magoga in forum mel PIC BASIC
    Replies: 0
    Last Post: - 3rd January 2013, 01:25
  3. Assigning particular value to a variable
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 31st July 2011, 00:22
  4. HSERIN for variable length string
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th February 2010, 05:58
  5. Assigning a variable to only a few pins?
    By Dayaks in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 28th August 2006, 00:21

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