akorx 0 Posted December 1, 2010 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 Share this post Link to post Share on other sites
whim 1 Posted December 1, 2010 Hi akorx !AutoIt has a function IsInt() Share this post Link to post Share on other sites
jchd 1,514 Posted December 1, 2010 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 hereRegExp tutorial: enough to get startedPCRE 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) Share this post Link to post Share on other sites
akorx 0 Posted December 1, 2010 (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 December 1, 2010 by akorx AkorxMail akorx@yahoo.fr Share this post Link to post Share on other sites
jchd 1,514 Posted December 1, 2010 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 hereRegExp tutorial: enough to get startedPCRE 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) Share this post Link to post Share on other sites
akorx 0 Posted December 1, 2010 Pardon ?What does ConsoleWrite(IsInt("a") & @LF)print for you?It returns "0" ... AkorxMail akorx@yahoo.fr Share this post Link to post Share on other sites
jchd 1,514 Posted December 1, 2010 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 hereRegExp tutorial: enough to get startedPCRE 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) Share this post Link to post Share on other sites
akorx 0 Posted December 1, 2010 (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 December 1, 2010 by akorx AkorxMail akorx@yahoo.fr Share this post Link to post Share on other sites
hannes08 39 Posted December 1, 2010 Hi akorx, please try StringIsInt(). This gives you the right answers... 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] Share this post Link to post Share on other sites
Alek 3 Posted December 1, 2010 (edited) StringIsInt should do the job edit: argh, too slow Edited December 1, 2010 by Alek [font="Impact"]Never fear, I is here.[/font] Share this post Link to post Share on other sites
jchd 1,514 Posted December 1, 2010 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 hereRegExp tutorial: enough to get startedPCRE 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) Share this post Link to post Share on other sites
akorx 0 Posted December 1, 2010 Yes it works !!! Big thanks guys for your help, you are kings !!!!!! AkorxMail akorx@yahoo.fr Share this post Link to post Share on other sites