PDA

View Full Version : Assigning a string variable to another string variable



Christopher4187
- 2nd June 2013, 14:09
I'm so close I can smell it.

I'm using this to get my data:

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:

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.

HenrikOlsson
- 2nd June 2013, 14:52
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

i VAR BYTE
For i = 0 to 254
UNIT1[i] = DAT[i]
NEXT

/Henrik.

Christopher4187
- 2nd June 2013, 17:55
I'm not quite sure what I'm doing but your technique worked well.

Thanks.