|
From: hugoliang on 19 Jun 2008 06:40 Dear All, How can I know a string only includes number(0,1,...9). Except to judge one character by one character. And How to judge it is an integer not a decimal fraction. Is there a vi to do it? Thanks for any suggestion. Hugo
From: GerdW on 19 Jun 2008 07:10 Hi Hugo,well, the difference between integer and fractional numbers is the decimal separator sign (either "." or ",", depending on location/OS setting). As you are testing for "only includes numbers" this is already given in the test...To test full strings for numbers you can use this:<img src="http://forums.ni.com/attachments/ni/170/333128/1/TestNumbers.png">The string is converted to U8 array and tested for "In Range" of all chars in the string... Message Edited by GerdW on 06-19-2008 12:45 PM TestNumbers.png: http://forums.ni.com/attachments/ni/170/333128/1/TestNumbers.png
From: Mythilt on 19 Jun 2008 09:10 One question since you asked about decimal vs fraction. Do you want fractional values to be considered numbers? Many people forget that '.' (or ',' for some countries) is a character as well when they look to see if a string is a number. If you want fractionals to be considered a number, you will have to account for the separator.
From: JoeLabView on 19 Jun 2008 09:10 The way I do it is to convert everything to ASCII and scan for the range of numbers as shown in the example, and also look for the period and comma. That covers all angles. RayR
From: JoeLabView on 19 Jun 2008 09:40 As shown in this example: <img src="http://forums.ni.com/attachments/ni/170/333202/1/numberCheck.PNG"> Message Edited by JoeLabView on 06-19-2008 09:24 AM numberCheck.PNG: http://forums.ni.com/attachments/ni/170/333202/1/numberCheck.PNG
|
Next
|
Last
Pages: 1 2 Prev: Unix Console App: serial communication Next: slight changes to vi needed |