04-19-2021 02:31 PM
Hi,
I would to convert my Response string (PM=2) command to Number. I use the Decimal String to Number. Later on that number is compared to get indication. I am not sure why I see 0 at downside.
Command: PM (power up mode)
Response: PM=2
I would like to get the number "2" from the response to compare it. But I get "0" when I look through the probe.
Any suggestion?
Solved! Go to Solution.
04-19-2021 02:35 PM
Because it converts a string number to a number. You are sending it PM= which are not numbers. You need to strip off the PM= and send the rest to the decimal string to number function. It is not smart enough to figure out what you want to use in the string.
Only send the 2.
04-19-2021 02:40 PM - edited 04-19-2021 02:56 PM
@aeastet wrote:
Because it converts a string number to a number. You are sending it PM= which are not numbers. You need to strip off the PM= and send the rest to the decimal string to number function. It is not smart enough to figure out what you want to use in the string.
Only send the 2.
For the OP:
Yes, this is correct. if you clicked on the "Detailed help" link, you would have found that out.
Edit:
That sounded a little terse. I wasn't admonishing the OP; just pointing out that more help can be found by clicking that link.
04-19-2021 03:01 PM
There are better choices than Decimal String to Number.
Such as Scan from String.
04-19-2021 03:14 PM - edited 04-19-2021 03:28 PM
Since you wire an offset, things should work just fine. Are you sure 4 is correct? Can you show us the actual received string (not with a probe, but with an indicator set to e.g. hex or \-codes display)
04-19-2021 03:17 PM
You need to send an offset of 3 not 4
04-19-2021 03:28 PM
As a general note, if you don't know in advance where in your string the number is going to start, you can use the "Match pattern" node like this:
That will look for the first digit it finds, then keep going until it finds a non-numeric character. So if you later want to use this on a different string, or make it a generic reusable subVI, you can use that technique instead of just a fixed string offset.