Cyri Posted February 23, 2010 Share Posted February 23, 2010 (edited) I know this is going to be a stupid question but here goes. Why does the following code not work as expected? Both cases are evaluated to be true. I'm running the latest production code 3.3.4.0.$test = "testing" Select Case $test <> "" MsgBox(0, "", "$test is not equal to nothing") ContinueCase Case $test = "" MsgBox(0, "", "$test is equal to nothing") EndSelectI know the above example is better suited for a Switch statment, but I'm just using it as an example. The one in my actual script is more complex and validates different expressions in each case. Edited February 23, 2010 by Cyri Link to comment Share on other sites More sharing options...
flyingboz Posted February 23, 2010 Share Posted February 23, 2010 short answer is variable types.. try ensuring you are using the proper operands or generating the proper values to test strings or numbers. to test for empty strings, I often use StringLen($var), for example. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
trancexx Posted February 23, 2010 Share Posted February 23, 2010 short answer is variable types..try ensuring you are using the proper operands or generating the proper values to test strings or numbers. to test for empty strings, I often use StringLen($var), for example. ContinueCase continues case. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 23, 2010 Share Posted February 23, 2010 No, the only problem is improper expectations of ContinueCase. When you do ContinueCase, the next case is unconditionally executed. Doesn't seem right to me, but that's how it works. I would have expected ContinueCase to go to the next Case test, not unconditionally execute it. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Cyri Posted February 23, 2010 Author Share Posted February 23, 2010 No, the only problem is improper expectations of ContinueCase. When you do ContinueCase, the next case is unconditionally executed. Doesn't seem right to me, but that's how it works. I would have expected ContinueCase to go to the next Case test, not unconditionally execute it.Thanks for the clarification on that. I would have also expected it to evaluate the next case expression. The documentation on ContinueCase doesn't really spell that out either. Link to comment Share on other sites More sharing options...
jchd Posted February 24, 2010 Share Posted February 24, 2010 (edited) Your initial interpretation wouldn't make sense in a Switch where Cases shouldn't overlap. That's why ContinueCase is harder to emulate with If... Should ContinueCase have "jumped" to the test of the next Case, then it would merely be a syntactic sugar. Select Case $x = 1 ; do something ContinueCase Case $x = 2 ; <-- assume ContinueCase would get you here ; do something else ... could have been simply written: If $x = 1 Then ; do something Endif If $x = 2 Then ; do something else ... But if you want to emulate the actual specific behavior of ContinueCase, you have to make it less simple and less readable: Local $skip = 0 If $x = 1 Then ; do something $skip = 1 Endif If $x = 2 Or $skip Then ; do something else ... Edited February 24, 2010 by jchd 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