writerturtle Posted April 8, 2016 Share Posted April 8, 2016 When I remove the commented Else statement, I get a number of errors. Tidy tells me "Else is closing previous Case" and I get a ton of syntax errors as well. I can't seem to use an else, or elseif statement no matter how I switch things around. I suspect that it might have to do with my long If And Or string for the $OkayButton, but similarly I don't know how to make that work otherwise. Basically there are two fields, $OriginalInput and $ShortcutInput that both need to not be null and direct to a real directory, in which case the program will continue. Any help is appreciated. While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $OkayButton If GUICtrlRead($ShortcutInput) = "" Or GUICtrlRead($OriginalInput) = "" Or FileExists(GUICtrlRead($ShortcutInput)) = False Or FileExists(GUICtrlRead($OriginalInput)) = False Then MsgBox($MB_SYSTEMMODAL, "Error", ("Something went wrong. Please select a valid directory.")) ;Else If MsgBox($MB_SYSTEMMODAL, "Good", ("All is good.")) Case $nMsg = $ShortcutBrowse $txt = FileSelectFolder("Open", "C:\") GUICtrlSetData($ShortcutInput, $txt) Case $nMsg = $OriginalBrowse $txt = FileSelectFolder("Open", "C:\") GUICtrlSetData($OriginalInput, $txt) EndSelect WEnd Link to comment Share on other sites More sharing options...
RTFC Posted April 8, 2016 Share Posted April 8, 2016 If GUICtrlRead($ShortcutInput) = "" Or GUICtrlRead($OriginalInput) = "" Or FileExists(GUICtrlRead($ShortcutInput)) = False Or FileExists(GUICtrlRead($OriginalInput)) = False Then MsgBox($MB_SYSTEMMODAL, "Error", ("Something went wrong. Please select a valid directory.")) Else MsgBox($MB_SYSTEMMODAL, "Good", ("All is good.")) Endif writerturtle 1 My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
writerturtle Posted April 8, 2016 Author Share Posted April 8, 2016 13 minutes ago, RTFC said: If GUICtrlRead($ShortcutInput) = "" Or GUICtrlRead($OriginalInput) = "" Or FileExists(GUICtrlRead($ShortcutInput)) = False Or FileExists(GUICtrlRead($OriginalInput)) = False Then MsgBox($MB_SYSTEMMODAL, "Error", ("Something went wrong. Please select a valid directory.")) Else MsgBox($MB_SYSTEMMODAL, "Good", ("All is good.")) Endif This fixes the problem exactly! I have spent hours on this! And I thought I got it, except I tried altering the code a little to see if I really got it and I clearly don't. If I split that long line into two separate messages, I get the exact same error codes as before: Case $nMsg = $OkayButton If GUICtrlRead($ShortcutInput) = "" Or GUICtrlRead($OriginalInput) = "" Then MsgBox($MB_SYSTEMMODAL, "Error", ("Please select a two directories.")) ElseIf FileExists(GUICtrlRead($ShortcutInput)) = False Or FileExists(GUICtrlRead($OriginalInput)) = False Then MsgBox($MB_SYSTEMMODAL, "Error", ("Something went wrong. Please select a valid directory.")) Else MsgBox($MB_SYSTEMMODAL, "Good", ("All is good.")) EndIf What do I keep doing wrong? Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2016 Developers Share Posted April 8, 2016 (edited) Case $nMsg = $OkayButton If GUICtrlRead($ShortcutInput) = "" Or GUICtrlRead($OriginalInput) = "" Then MsgBox($MB_SYSTEMMODAL, "Error", ("Please select a two directories.")) ElseIf FileExists(GUICtrlRead($ShortcutInput)) = False Or FileExists(GUICtrlRead($OriginalInput)) = False Then MsgBox($MB_SYSTEMMODAL, "Error", ("Something went wrong. Please select a valid directory.")) Else MsgBox($MB_SYSTEMMODAL, "Good", ("All is good.")) EndIf Edited April 8, 2016 by Jos writerturtle 1 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. Link to comment Share on other sites More sharing options...
writerturtle Posted April 8, 2016 Author Share Posted April 8, 2016 9 minutes ago, Jos said: Case $nMsg = $OkayButton If GUICtrlRead($ShortcutInput) = "" Or GUICtrlRead($OriginalInput) = "" Then MsgBox($MB_SYSTEMMODAL, "Error", ("Please select a two directories.")) ElseIf FileExists(GUICtrlRead($ShortcutInput)) = False Or FileExists(GUICtrlRead($OriginalInput)) = False Then MsgBox($MB_SYSTEMMODAL, "Error", ("Something went wrong. Please select a valid directory.")) Else MsgBox($MB_SYSTEMMODAL, "Good", ("All is good.")) EndIf Again, that works perfectly, but this time I can't even see what you changed from my version... Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2016 Developers Share Posted April 8, 2016 (edited) 4 minutes ago, writerturtle said: but this time I can't even see what you changed from my version Are you sure you looked at it carefully? I added some Then words and separated the ElseIF ... Then and Else statement from their next statement, putting it on its own line. Format is everything! Jos Edited April 8, 2016 by Jos 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. Link to comment Share on other sites More sharing options...
writerturtle Posted April 8, 2016 Author Share Posted April 8, 2016 1 minute ago, Jos said: Are you sure you looked at it carefully? I added some Then words and separated the ElseIF ... Then statement for the next statement, putting it on its own line. Format is everything! Jos I have been scripting in AutoIt for three days now and I didn't know until just now that lines mattered like that. There are no markers for the end of lines so I didn't think it mattered (like in C# you have to end every line of code in a semicolon). I saw that you did that, but I thought you were just making the code tidy. Thanks so much for the help! Link to comment Share on other sites More sharing options...
Developers Jos Posted April 8, 2016 Developers Share Posted April 8, 2016 The helpfile will explain the 2 formats for If..Else--EndIf statements we have. Jos writerturtle 1 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. 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