Realm Posted November 16, 2011 Share Posted November 16, 2011 (edited) I found my self confuzzled and cornered. However I'm sure someone here has ran across this lil problem, and may have found or know of a solution. I'm reading a inifile, then trimming the first character in the string and testing if it is an integer. However I have found that if a number is in string format, that IsInt() will not return it as an integer. same goes for IsNumber() Example: Local $aString[3] = ['Test', '2', 3] For $i = 0 To UBound( $aString ) - 1 MsgBox('','', IsNumber( $aString[$i])) ;returns only the last one as Int MsgBox('','', IsNumber( Int($aString[$i]))) ;returns all three as Int MsgBox('','', IsInt( $aString[$i])) ;also returns only the last one as Int MsgBox('','', IsInt( Int($aString[$i]))) ;again returns all three as Int Next I have attempted to write my own solution Local $aString[3] = ['N', '2', 3] For $i = 0 To UBound( $aString ) - 1 MsgBox('',$aString[$i], _IsStringCharNum($aString[$i])) Next Func _IsStringCharNum( $sString ) If StringLen( $sString ) > 1 Then Return SetError(1) For $z = 0 To 9 If $z = $sString Then Return (1) Next Return (0) EndFunc This does return the stringed '2' as an integer however it counts letters as 0, thus everything is returned as an integer. Hopefully someone has found a solution to this lil dilemma. Edit: NVM, While reading over IsInt() in the helpfile for the third time, found the link to StringIsInt() *Embarrased* Edited November 16, 2011 by Realm My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted November 16, 2011 Share Posted November 16, 2011 Your function above would have worked if you made a string comparison. If $z == $sString .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Realm Posted November 16, 2011 Author Share Posted November 16, 2011 I always forget about that operator. Thanks! My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now