Jump to content

IsNumber


erebus
 Share

Recommended Posts

I use the following code:

$no=1

Select
   Case Not IsNumber($no)
   MsgBox(0, "DEBUG", "$no is not a number")
   Exit
EndSelect

This works as expected. $no IS a number.

Now I alter the above code as:

$no = IniRead($ini, "Something", "Number", "NOTEXIST")

Select
   Case Not IsNumber($no)
   MsgBox(0, "DEBUG", "$no is not a number")
   MsgBox(0, "DEBUG", $no + 1)
   Exit
EndSelect

"Number" in $ini = 1. Now AutoIT does not recognize $no as a number, executes the first MsgBox to indicate the error, however the result of the second MsgBox is "2". Can you explain this?

If I'm doing something really stupid (headache rules) shoot me freely.

Link to comment
Share on other sites

@Larry: Why can't I find this function? (using the latest unstable)

@Mr.Wizard: Just posted a sort example, there are more conditions in my case (that's why the Select function was used).

Edit: Solved - used:

$no = IniRead($ini, "Something", "Number", "NOTEXIST")

Select
   Case Not Number($no)

Thanks anyway guys :)

Edited by erebus
Link to comment
Share on other sites

  • Developers

@Larry: Why can't I find this function? (using the latest unstable)

@Mr.Wizard: Just posted a sort example, there are more conditions in my case (that's why the Select function was used).

Edit: Solved - used:

$no = IniRead($ini, "Something", "Number", "NOTEXIST")

Select
   Case Not Number($no)

Thanks anyway guys :)

<{POST_SNAPBACK}>

Try this and see if that explains it:

$no = 1
if Not IsNumber($no) then MsgBox(0, "DEBUG 1 ", "$no is not a number")
$no = "1"
if Not IsNumber($no) then MsgBox(0, "DEBUG 2", "$no is not a number")

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

@JdeB: Thank you, I also got the same answer from Larry:

IniRead returns a string...

@SlimShady: Very good idea! Already updated, thank you. :) I think that is what Larry means. Edited by erebus
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...