Jump to content

Recommended Posts

Posted

Hi guys,

Sorry for my bad english i'm french...

Do you know how can i test the type of a variable ? i use "cmdline" command to give parameters to my script and parameters must be integers :

exemple :

myscript 1 2 3

if i make a mistake like this :

myscript 1 a 3

it works ! the string "a" seems to be recognized as the number "0" and i don't want !! have you got an idea to solve my problem ?

AkorxMail akorx@yahoo.fr

Posted

Use the Is* functions: IsNumber, IsInt, IsFloat, ...

This is correct, Number("a") = 0 by convention/feature.

Et voilĂ .

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)

Hi akorx !

AutoIt has a function IsInt()

Thanks you for your help but it does't work ! in my exemple the string "a" is recognize as a "0" (zero) and so the function "isint()" returns "1" (= true"), however "a" is a string and not a number...

Edited by akorx

AkorxMail akorx@yahoo.fr

Posted

Pardon ?

What does

ConsoleWrite(IsInt("a") & @LF)

print for you?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Well, and

ConsoleWrite(IsInt("3") & @LF)

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted (edited)

Well, and

ConsoleWrite(IsInt("3") & @LF)

Same thing, it returns "0"...

Someone should have known the problem... no ?

I'm going to eat, i'll be back in few minutes...

Edited by akorx

AkorxMail akorx@yahoo.fr

Posted

Hi akorx,

please try StringIsInt(). This gives you the right answers...

:graduated:

ConsoleWrite($CmdLine[1] & @TAB & StringIsInt($CmdLine[1]) & @CRLF)
ConsoleWrite($CmdLine[2] & @TAB & StringIsInt($CmdLine[2]) & @CRLF)

or

ConsoleWrite("10" & @TAB & StringIsInt("10") & @CRLF)
ConsoleWrite("abc" & @TAB & StringIsInt("abc") & @CRLF)

Regards,

Hannes

Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler]
Posted (edited)

StringIsInt should do the job

edit:

argh, too slow :graduated:

Edited by Alek

[font="Impact"]Never fear, I is here.[/font]

Posted

Geez, I'm really slow today.

Of course StringIsInt is the right function.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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