BS2, Concatenating (not adding) multiple values from GETs into single VAR?
xanatos
Posts: 1,120
Hi there,
I have several single digit values generated in one slot of my BS2sx programs that are PUT into specific locations.
In another slot I GET those values. They are all single-digit DEC values (0-9).
I need to group them into single variables of three digits each (long story).
Other than GET 1, multiply it by ten, add GET 2, multiply that by 10 and add GET 3 - is there a more eloquent way to concatenate the values? Something equivalent to
someVar = DEC1 (GET 1) & DEC1 (GET 2) & DEC1 (GET 3)
:-)
Thanks,
Dave
I have several single digit values generated in one slot of my BS2sx programs that are PUT into specific locations.
In another slot I GET those values. They are all single-digit DEC values (0-9).
I need to group them into single variables of three digits each (long story).
Other than GET 1, multiply it by ten, add GET 2, multiply that by 10 and add GET 3 - is there a more eloquent way to concatenate the values? Something equivalent to
someVar = DEC1 (GET 1) & DEC1 (GET 2) & DEC1 (GET 3)
:-)
Thanks,
Dave
Comments
GET 0, X
Answer = X - "0"
GET 1, X
Answer = Answer * 10 + X - "0"
If the number form allows it, you could do this in a FOR loop
TRKMLG = (100 * d6) + (10 * d5) + d4
TRKMLG2 = (100 * d3) + (10 * d2) + d1
Then I just use a DEC3 when I send the two variables. Works fine.
Thanks,
Dave