TheAutomator Posted March 4, 2014 Share Posted March 4, 2014 (edited) what am I doing wrong here? Func char_ok($input) Local $arr = [ 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', _ 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', _ 0,1,2,3,4,5,6,7,8,9 ] For $x = 1 To UBound($arr) If $arr[$x - 1] = $input Then Return True Next Return False EndFunc MsgBox(0,0,char_ok('-')) The '-' is not in the array so why is it true? TheAutomator. Edited March 4, 2014 by TheAutomator Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
Solution FireFox Posted March 4, 2014 Solution Share Posted March 4, 2014 Hi, The problem is when you are comparing a number with your input so your input (which is a string) is converted to a number. As your input can not be converted to a number, it equals 0. Hence it matches the 0 in your array. To avoid this add quotes to have strings and not numbers. Br, FireFox. Link to comment Share on other sites More sharing options...
TheAutomator Posted March 4, 2014 Author Share Posted March 4, 2014 FireFox, hey, it works. Thanks TheAutomator. Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
jchd Posted March 4, 2014 Share Posted March 4, 2014 What Firefox said. Also you'd better use a regular expression for this validation: Func char_ok($input) Return (StringRegExp($input, '(?i)^[[:alnum:]]$') = 1) EndFunc MsgBox(0, 0, char_ok('Zr')) 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) Link to comment Share on other sites More sharing options...
TheAutomator Posted March 4, 2014 Author Share Posted March 4, 2014 jchd, Also you'd better use a regular expression for this validation I know, but i'm not so familiar with regular expressions and I don't find any good tutorials for it.. but thanks for the info TheAutomator. Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 4, 2014 Moderators Share Posted March 4, 2014 (edited) jchd, I know, but i'm not so familiar with regular expressions and I don't find any good tutorials for it.. but thanks for the info TheAutomator. You would find one quickly if you cracked open the help file. Not only is there a Regular Expression Tutorial, there are links to other resources. All you have to do is look. Edited March 4, 2014 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
TheAutomator Posted March 4, 2014 Author Share Posted March 4, 2014 JLogan3o13, you're right, sometimes I read to fast and miss this things. only read the part that explains StringRegExp .. I will take a look at it TheAutomator. Retro Console, NestedArrayDisplay UDF foldermaker-pro-clone Link to comment Share on other sites More sharing options...
jchd Posted March 4, 2014 Share Posted March 4, 2014 Good reading! 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) 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