mr-es335 Posted 19 hours ago Posted 19 hours ago (edited) Hello, I am attempting - rather unsuccessfully, to implement If|Then within a Switch|Case script. Here is the script: expandcollapse popup; ----------------------------------------------- #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $iEMBWidth = 650 Global $iMsgDelay = 4 ; ----------------------------------------------- IfGFoldersExist() ; ----------------------------------------------- Func IfGFoldersExist() Local $condition Local $iStart = 11, $iEnd = 10 Local $sFolder[$iStart] = [$iEnd] $sFolder[1] = "G:\AltPeakData" $sFolder[2] = "G:\Automation_Data" $sFolder[3] = "G:\CHT_Files" $sFolder[4] = "G:\ControlTrack_Data" $sFolder[5] = "G:\F-Key_Data" $sFolder[6] = "G:\Mix_Templates" $sFolder[7] = "G:\Prf_Data" $sFolder[8] = "G:\Scene_Data" $sFolder[9] = "G:\Session_Data" $sFolder[10] = "G:\Session_Master" ; ----------------- Local $iFolderExists[$iStart] = [$iEnd] $iFolderExists[1] = FileExists($sFolder[1]) $iFolderExists[2] = FileExists($sFolder[2]) $iFolderExists[3] = FileExists($sFolder[3]) $iFolderExists[4] = FileExists($sFolder[4]) $iFolderExists[5] = FileExists($sFolder[5]) $iFolderExists[6] = FileExists($sFolder[6]) $iFolderExists[7] = FileExists($sFolder[7]) $iFolderExists[8] = FileExists($sFolder[8]) $iFolderExists[9] = FileExists($sFolder[9]) $iFolderExists[10] = FileExists($sFolder[10]) ; ----------------- Local $sMessage = "Confirm if folders exist..." & @CRLF & @CRLF, $iWidth = 500, $iHeight = 390 Local $iOpt = 5, $sFontName = "Corbel Bold", $iFontSize = 16 ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) ; ----------------------------------------------- For $i = 1 To $sFolder[0] Local $sResult = FileExists($sFolder[$i]) ;~ Local $sResult = "" ; For testing only!! ; ----------------------------------------------- Switch $sResult Case 0 $sResult = "The folder [" & $sFolder[$i] & "] DOES NOT exist!" Case 1 $sResult = "The folder [" & $sFolder[$i] & "] DOES exist!" EndSwitch ; ----------------------------------------------- $sMessage &= $sResult & @CRLF Next ; ----------------------------------------------- $sMessage &= @CRLF & "Confirm if folders exist is now completed..." & @CRLF ; ----------------------------------------------- SplashTextOn("", $sMessage, $iWidth, $iHeight, -1, -1, $iOpt, $sFontName, $iFontSize) Sleep(3500) SplashOff() ; ----------------------------------------------- ; My attempt!! ;~ If $sResult <> $sFolder[10] Then ;~ RestoreInitialFolderData() ;~ EndIf ;~ If $sResult = $sFolder[1] Then ;~ Notice() ;~ EndIf EndFunc ;==>IfGFoldersExist ; ----------------------------------------------- Func RestoreInitialFolderData() MsgBox($MB_SYSTEMMODAL, "Title", "RestoreInitialFolderData", 2) EndFunc ;==>RestoreInitialFolderData ; ----------------------------------------------- Func Notice() MsgBox($MB_SYSTEMMODAL, "Title", "Done!", 2) EndFunc ;==>Notice ; ----------------------------------------------- If Case = 0, I then need to call the "RestoreInitialFolderData()" function If Case = 1, I then need to call the "Notice()" function Any ideas!! Edited 19 hours ago by mr-es335 mr-es335 Sentinel Music Studios
argumentum Posted 18 hours ago Posted 18 hours ago (edited) ;~ If Case = 0, I then need to call the "RestoreInitialFolderData()" function ;~ If Case = 1, I then need to call the "Notice()" function Switch FileExists($sFolder[$i]) Case 1 $sResult = "The folder [" & $sFolder[$i] & "] DOES exist!" Notice() Case Else $sResult = "The folder [" & $sFolder[$i] & "] DOES NOT exist!" RestoreInitialFolderData() EndSwitch Edit: ...I have no idea. Edited 18 hours ago by argumentum oops mr-es335 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Developers Jos Posted 18 hours ago Developers Posted 18 hours ago (edited) Just learn to add some consolewrite() statements for key variables to debug! Wild guess: wrong value in: $sFolder[0] Edited 6 hours ago by Jos mr-es335 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.
mr-es335 Posted 13 hours ago Author Posted 13 hours ago Hello, Okay! How is this: 1) If Case = 0, I then need to call a function that copies this data. 2) If Case = 1, does anything need to be done here? How do I implement #1? mr-es335 Sentinel Music Studios
Developers Jos Posted 6 hours ago Developers Posted 6 hours ago (edited) So what did you do yourself this time, other than only ask a question again? Edited 5 hours ago 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.
mr-es335 Posted 1 hour ago Author Posted 1 hour ago Jos, Y9ou stated, "Just learn to add some consolewrite() statements for key variables to debug!" I DID do that...and no success! mr-es335 Sentinel Music Studios
Developers Jos Posted 1 hour ago Developers Posted 1 hour ago What did you do, what were the results and what isn't working yet? .... as my crystal ball is broken. 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.
argumentum Posted 1 hour ago Posted 1 hour ago 17 hours ago, argumentum said: Edit: ...I have no idea. ...that is because: ... Local $iStart = 11, $iEnd = 10 Local $sFolder[$iStart] = [$iEnd] $sFolder[1] = "G:\AltPeakData" $sFolder[2] = "G:\Automation_Data" $sFolder[3] = "G:\CHT_Files" $sFolder[4] = "G:\ControlTrack_Data" $sFolder[5] = "G:\F-Key_Data" $sFolder[6] = "G:\Mix_Templates" $sFolder[7] = "G:\Prf_Data" $sFolder[8] = "G:\Scene_Data" $sFolder[9] = "G:\Session_Data" $sFolder[10] = "G:\Session_Master" ; ----------------- Local $iFolderExists[$iStart] = [$iEnd] $iFolderExists[1] = FileExists($sFolder[1]) $iFolderExists[2] = FileExists($sFolder[2]) $iFolderExists[3] = FileExists($sFolder[3]) $iFolderExists[4] = FileExists($sFolder[4]) $iFolderExists[5] = FileExists($sFolder[5]) $iFolderExists[6] = FileExists($sFolder[6]) $iFolderExists[7] = FileExists($sFolder[7]) $iFolderExists[8] = FileExists($sFolder[8]) $iFolderExists[9] = FileExists($sFolder[9]) $iFolderExists[10] = FileExists($sFolder[10]) ; ----------------- ... makes no sense. Why would you code it that way !?. It just don't make any sense. ... ; you can make a file and read from it or ; declare it just like this: $sFolders = "G:\AltPeakData" & @CRLF $sFolders &= "G:\Automation_Data" & @CRLF $sFolders &= "G:\CHT_Files" & @CRLF $sFolders &= "G:\ControlTrack_Data" & @CRLF $sFolders &= "G:\F-Key_Data" & @CRLF $sFolders &= "G:\Mix_Templates" & @CRLF $sFolders &= "G:\Prf_Data" & @CRLF $sFolders &= "G:\Scene_Data" & @CRLF $sFolders &= "G:\Session_Data" & @CRLF $sFolders &= "G:\Session_Master" & @CRLF ; then chop that into an array $aFolders = StringSplit($sFolders, @CRLF, 1) ; make the $aFolderExists array based of $aFolders Local $aFolderExists = $aFolders ; lazy way but it will work ; then use a for loop For $n = 1 To UBound($aFolders) - 1 If $aFolders[$n] = "" Then ContinueLoop $aFolderExists[$n] = FileExists($aFolders[$n]) ConsoleWrite(($aFolderExists[$n] = 0 ? '!' : '+') & ' This is at index ' & $n & ' and contains this string: "' & _ $aFolders[$n] & '" and does ' & ($aFolderExists[$n] = 0 ? 'not ' : '') & 'exist.'& @CRLF) Next ... You have over 600 posts and, what have you learned ?. You are going to have to slow down your hurry to get your code done. Because you lack flexibility. You don't know how to use a "for loop" and that is a shame. And do use the "F1" key in the editor. Most of the answers given to you are right there Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Developers Jos Posted 1 hour ago Developers Posted 1 hour ago ... and yet there's again somebody feeding laziness and stimulating the "please barf code for me" requests...... 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.
argumentum Posted 1 hour ago Posted 1 hour ago Not really. Just gave him a for loop example. The way it goes, is going to be a head scratcher for him. But after over 600 questions of always the same, c'mon !. The code is to tell him to slow down and learn. I've been there and do understand him. But in the end, there is only so much one gets done by copy and paste. Eventually the coder needs to know/learn or get ignored by the rest of the users Do you understand @mr-es335 that you are not in an "ignore list". You are just not showing independence of thought. Do learn or you'll be faced with more posts not been answered. And that is going to be painful as you already experienced this week in another post. Please do look at the help file we all actively contribute to maintain, and practice, practice, practice. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
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