Jump to content

Recommended Posts

Posted

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.

Posted

And why are you using a Select when there's only one condition? Why not use an If?

I have a catapult. Give me all the money or I will fling an enormous rock at your head.

Posted (edited)

@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
Posted

I suggest you use StringIsDigit

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

Select
  Case StringIsDigit($no)
     MsgBox(0, "DEBUG", "$no is not a number")
     MsgBox(0, "DEBUG", $no + 1)
     Exit
EndSelect
  • Developers
Posted

@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.
  :)

Posted (edited)

@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

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
×
×
  • Create New...