lovemachinez Posted April 3, 2012 Report Share Posted April 3, 2012 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 Thank you in advance. Quote Link to comment
dannyt Posted April 3, 2012 Report Share Posted April 3, 2012 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 Quote Link to comment
lovemachinez Posted April 3, 2012 Author Report Share Posted April 3, 2012 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. Quote Link to comment
crossrulz Posted April 3, 2012 Report Share Posted April 3, 2012 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. Quote Link to comment
EricLarsen Posted April 3, 2012 Report Share Posted April 3, 2012 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. Quote Link to comment
hooovahh Posted April 6, 2012 Report Share Posted April 6, 2012 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. Quote Link to comment
Darin Posted April 6, 2012 Report Share Posted April 6, 2012 You can dig it up through the Example finder, or here: ..\National Instruments\LabVIEW xxxx\examples\general\strings.llb\Extract Numbers.vi 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.