Jump to content

String is Int or Float [solved]


Recommended Posts

I see.

Is it because Autoit3 is loosely typed, that the statement is valid?

12 months ago I wouldnt of even asked such a question, but after poking around other languages it looks out of place saying "Checks if a string is an integer"

Probably splitting hairs, suggesting a change to the helpfile with that I suppose.

EDIT:

The same with IsInt()

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Mmm, seems solved to dead.

Always good to setup a little test case, to see(compare) the results on different data and different functions.

#include "array.au3"
test()
Exit

Func test()
    Local Enum $_data_
    Local $aData[8][1 + 4] = [['123'],['1.23'],['1.2.3'],['0'],[''],['abc'],['123abc'],['abc123']]

    For $iData = 0 To UBound($aData, 1) - 1
        For $iCase = 1 To UBound($aData, 2) - 1
            $aData[$iData][$iCase] = Execute('case' & String($iCase) & '("' & $aData[$iData][$_data_] & '")')
        Next
    Next
    _ArrayDisplay($aData)

EndFunc
Func case1($sNum) ;; one funct at a time.(x3)
    Return StringIsInt($sNum)
EndFunc
Func case2($sNum)
    Return StringIsFloat($sNum)
EndFunc
Func case3($sNum)
    Return StringRegExp($sNum, "^\d*\.?\d+$")
EndFunc
Func case4($sNum) ;; bool version.
    Return StringIsInt($sNum) Or StringIsFloat($sNum)
EndFunc

E:+#include

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...