06-30-2022 08:25 AM
hello everyone,
im receiving 12 character string from the sensor which is changeable after every read( For example ) 04C613E81E00. i just want to divide it separately in three equal part such as 04C6, 13E8, 1E00(1st part 04C6, 2nd part 13E8, 3rd part 1E00). can someone tell me how to do it? i tried with split string but as it is changeable data im not able o do it with split string.
Thank you in advance 🙂
Solved! Go to Solution.
06-30-2022 08:27 AM - edited 06-30-2022 08:32 AM
Hi 123,
@newmemeber123 wrote:
im receiving 12 character string from the sensor which is changeable after every read( For example ) 04C613E81E00. i just want to divide it separately in three equal part such as 04C6, 13E8, 1E00(1st part 04C6, 2nd part 13E8, 3rd part 1E00). can someone tell me how to do it? i tried with split string but as it is changeable data im not able o do it with split string.
What have you tried with SplitString that "does not work"?
I recommend to use ScanFromString with a format string of "%4s%4s%4s":
06-30-2022 08:56 AM
thank you so much. i tried the same %4, %4,%4 was missed, silly mistake thank you
06-30-2022 09:23 AM - edited 06-30-2022 09:24 AM
Or if you need numerics in the end...
06-30-2022 09:40 AM
Thank you both. its working. I have another question i have converted these numbers to decimal and i have to compare these three number with another decimal number separately with less than sign and if it is less than it then that case should execute.... should i use the the case struct or something new you will suggest? because it is showing error while i use case structure.
screenshot is attached of my try.
06-30-2022 09:44 AM
@newmemeber123 wrote:
Thank you both. its working. I have another question i have converted these numbers to decimal and i have to compare these three number with another decimal number separately with less than sign and if it is less than it then that case should execute.... should i use the the case struct or something new you will suggest? because it is showing error while i use case structure.
screenshot is attached of my try.
When you compare one array to another, you get an array of results. You cannot use an array of results for your case selector.
06-30-2022 09:52 AM
thank you.
can you suggest me please? How can i compare these numbers and if they are lesser other then next condition should execute.
looking forward to your help
thank you 🙂
06-30-2022 10:01 AM
@newmemeber123 wrote:
thank you.
can you suggest me please? How can i compare these numbers and if they are lesser other then next condition should execute.
looking forward to your help
thank you 🙂
You should probably have 3 case structures. Depending on what is happening in them, you could use a FOR loop to only execute the case if that value is less, using the i terminal as an input for whatever is happening inside of the case structure.
06-30-2022 11:45 AM
thank you..do you have a similar example ? or link of similar example?
06-30-2022 12:07 PM
@newmemeber123 wrote:
thank you..do you have a similar example ? or link of similar example?
What are you actually trying to do with these case structures?