Lope 0 Posted September 3, 2011 (edited) I know this is a seemingly retarded question. But I've checked the manual, I've googled, and I've searched the forum. I've tried IsInt and IsNumber and @error. $foo='45' Messagebox(0,'',Int($foo)) ; returns 45 Messagebox(0,'',@error) ; returns 0, ok, thats expected... $foo='dfgfdg' Messagebox(0,'',Int($foo)) ; returns 0 Messagebox(0,'',@error) ; returns 0 < huh? $foo='45' Messagebox(0,'',IsNumber($foo)) ; returns 0... (not a numeric type) how does one check if a string converts completely to a number without errors? Edited September 3, 2011 by Lope Share this post Link to post Share on other sites
Rogue5099 18 Posted September 3, 2011 (edited) Checks if a string contains only digit (0-9) characters. StringIsDigit ( "string" ) StringIsDigit("12333") ;returns 1 StringIsDigit("1.5") ;returns 0 due to decimal point StringIsDigit("1 2 3") ;returns 0 due to whitespace StringIsDigit("") ;returns 0 Edited September 3, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Share this post Link to post Share on other sites
UEZ 1,274 Posted September 3, 2011 Try Number(): $w = Number(1+2+10) ;returns 13 MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$w' & @lf & @lf & 'Return:' & @lf & $w) ;### Debug MSGBOX $x = Number("3.14") ;returns 3.14 MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$x' & @lf & @lf & 'Return:' & @lf & $x) ;### Debug MSGBOX $y = Number("24/7") ;returns 24 MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$y' & @lf & @lf & 'Return:' & @lf & $y) ;### Debug MSGBOX $z = Number("tmp3") ;returns 0 MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & '$z' & @lf & @lf & 'Return:' & @lf & $z) ;### Debug MSGBOX Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
Bowmore 97 Posted September 3, 2011 This is a function that I wrote some time ago the identifies if a value is a number. "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Share this post Link to post Share on other sites
Jon 1,011 Posted September 3, 2011 I know this is a seemingly retarded question. But I've checked the manual, I've googled, and I've searched the forum.I've tried IsInt and IsNumber and @error. $foo='45'Messagebox(0,'',Int($foo)) ; returns 45Messagebox(0,'',@error) ; returns 0, ok, thats expected...You can't use @error like that. @error is being set by the first MessageBox so will always be 0 in this case. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
MvGulik 86 Posted September 3, 2011 (edited) mmm. "... (re)set first by the MessageBox() call itself so ..." Edited September 3, 2011 by iEvKI3gv9Wrkd41u "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)"Believing what you know ain't so" ...Knock Knock ... Share this post Link to post Share on other sites
SmOke_N 211 Posted September 4, 2011 Roll your own: Func _StringIsNumber($v_num) Return (Int(StringIsInt($v_num)) + Int(StringIsFloat($v_num)) > 0) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Share this post Link to post Share on other sites