Jump to content
lovemachinez

Please help, Convert this string format to number

Recommended Posts

I send some command via RS232 to my machine and the machine sent me back with a number "40" display in normal display in my attatched picture. I tried to use the string convert to num tools but there is nothing happen.

I wondering with it, then I try displaying the string in different way as in attached, code display and hex display.

I want to get the string "40" to change it to number, how can I get it? please help

90974344.gif

Thank you in advance.

post-15170-0-68335500-1333432524.gif

Share this post


Link to post
Share on other sites

Not totally sure I have understood your question correctly by string convert to number tools do you mean Scan From String ?

Scans the input string and converts the string according to format string.

Use this function when you know the exact format of the input. The input can be string, path, enumerated type, time stamp, or numeric data. Alternatively, you can use the Scan From File function to scan text from a file. The connector pane displays the default data types for this polymorphic function.

Would help if you showed you block diagram

Share this post


Link to post
Share on other sites

Not totally sure I have understood your question correctly by string convert to number tools do you mean Scan From String ?

Scans the input string and converts the string according to format string.

Use this function when you know the exact format of the input. The input can be string, path, enumerated type, time stamp, or numeric data. Alternatively, you can use the Scan From File function to scan text from a file. The connector pane displays the default data types for this polymorphic function.

Would help if you showed you block diagram

Thank you. I have already done with it. with this solution.

post-15170-0-26923700-1333441473.png

Share this post


Link to post
Share on other sites

What version are you using? How did you do it before? As far back as at least 8.6 (I don't currently have older to check), all you should have needed is the Decimal String to Number. It will find the number even with all of the white space.

post-11268-0-42539100-1333459752.png

Share this post


Link to post
Share on other sites

There is a vi in the examples called Extract Numbers.vi. It's perfect for this application. It takes a string as an input and converts it to an array of numbers. Then you simply index the array to extract the number you need. It's really useful when your string contains more than one number.

post-7727-0-35208400-1333461979.png

Share this post


Link to post
Share on other sites

I was expecting some neat little nugget from the VI.lib. Instead I found out that Eric needs to update one of his general VIs.

post-6627-0-09475500-1333736357.png

Share this post


Link to post
Share on other sites

You can dig it up through the Example finder, or here:

..\National Instruments\LabVIEW xxxx\examples\general\strings.llb\Extract Numbers.vi

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.