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.
Bookmarks