LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Value for Decimal String to Number

Solved!
Go to solution

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?

40.png

0 Kudos
Message 1 of 7
(217 Views)

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.

Tim
GHSP
0 Kudos
Message 2 of 7
(215 Views)

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

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 7
(204 Views)

There are better choices than Decimal String to Number.

 

Such as Scan from String.

Message 4 of 7
(183 Views)

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)


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 7
(169 Views)
Solution
Accepted by skdubey

You need to send an offset of 3 not 4

Tim
GHSP
Message 6 of 7
(166 Views)

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:

 

Kyle97330_0-1618864040143.png

 

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.

Message 7 of 7
(160 Views)