I vote for splitting hairs. If you *want* all of the data that's in there, the ATOI(REMOVE looks like the way to go.
- Chip
toggle quoted message
Show quoted text
--- In Crestron@..., "matt_rasmussen_2000" <mjrtoo@...> wrote:
Yeah, right, the string is not always the same, like I said, the attenuation value can be from 1 to 4 bytes long, for each channel. I was thinking of getting the LEN of the attenuation data, then MID the string based on that but seems more work than the removes anyway.
--- In Crestron@..., "jrw_96" <jrw_96@> wrote:
Use a buffer and collect everything in said buffer. Then just break it down as necessary. Only if the incoming strings are predictable and/or the end of the string is always \x0d\x0a...
If the above is true then this should be gravy for you. It's when you do NOT have set points (delimiter(s) and actual sub-headers differentiating the substring/channel info) [always seems to be my case with crc's and what not] that you have to wonder "is this really worth it" imo...
JRW
--- In Crestron@..., "matt_rasmussen_2000" <mjrtoo@> wrote:
Here's the string
0 0 0 0 1 0 0 0 0 0 0 0 -44 0 0 0 0 0 0 0 0 -27 0 0 0 0 0 0 0 1 -26 0 0 0 0 0 0 0 0\x0d\x0a
The first three 0's are status of the device itself, then the next group of 9 (not including spaces) are individual channel data. So channel 1 = 0 1 0 0 0 0 0 0 0
channel 2 = -44 0 0 0 0 0 0 0 0
channel 3 = -27 0 0 0 0 0 0 0 1
channel 4 = -26 0 0 0 0 0 0 0 0
the first set of chars before the first space can be 0...-100, all the other data is a single byte.
My method is using REMOVE statements like below
status1 = ATOI(REMOVE("\x20", rx$);
status2 = ATOI(REMOVE("\x20", rx$);
status3 = ATOI(REMOVE("\x20", rx$);
Attenuation[1] = REMOVE("\x20", rx$);
ch1Clip[1] = ATOI(REMOVE("\x20", rx$);
etc.,
all the way through the string. Not sure if it's even worth going through breaking up the string into channel groups and working on it that way. What do you think, splitting hairs?