mr-es335 Posted yesterday at 07:10 PM Posted yesterday at 07:10 PM (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 yesterday at 07:11 PM by mr-es335 mr-es335 Sentinel Music Studios
argumentum Posted yesterday at 07:29 PM Posted yesterday at 07:29 PM (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 yesterday at 07:34 PM 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 yesterday at 07:44 PM Developers Posted yesterday at 07:44 PM (edited) Just learn to add some consolewrite() statements for key variables to debug! Wild guess: wrong value in: $sFolder[0] Edited 13 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 20 hours ago Author Posted 20 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 13 hours ago Developers Posted 13 hours ago (edited) So what did you do yourself this time, other than only ask a question again? Edited 12 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 9 hours ago Author Posted 9 hours 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 9 hours ago Developers Posted 9 hours 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 8 hours ago Posted 8 hours 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 8 hours ago Developers Posted 8 hours 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 8 hours ago Posted 8 hours 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.
Developers Jos Posted 6 hours ago Developers Posted 6 hours ago 1 hour ago, argumentum said: But after over 600 questions of always the same, c'mon !. Hence I was very reluctant to give anything more than a pointer! 😉 argumentum 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 6 hours ago Author Posted 6 hours ago Okay! I DO understand that my coding is "long-and-repetitive"...but the script does what I need that code to do! How is this: expandcollapse popup; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- IfGFoldersExist() ; ----------------------------------------------- Func IfGFoldersExist() Local $iStart = 2, $iEnd = 1 Local $sFolder[$iStart] = [$iEnd] $sFolder[1] = "G:\AltPeakData" ; ----------------- Local $iFolderExists[$iStart] = [$iEnd] $iFolderExists[1] = FileExists($sFolder[1]) ; ----------------- Local $sMessage = "Confirm if folders exist..." & @CRLF & @CRLF, $iWidth = 500, $iHeight = 156 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(3000) SplashOff() EndFunc ;==>IfGFoldersExist ; ----------------------------------------------- All that I am asking is that I need to know how to use the Code 0 to execute a 2nd script to copy the missing data. I have been doing this manually with two scripts, but I am unable to do this in a single script. PS: I am using SplashTextOn() simply because my eyesight is not what it used to be. Using MsgBox() has the text so small that I am unable to read the text. Also, I do not believe that I AM asking for "barf code". I am stuck and I need to know to get unstuck. mr-es335 Sentinel Music Studios
argumentum Posted 6 hours ago Posted 6 hours ago 9 minutes ago, mr-es335 said: Also, I do not believe that I AM asking for "barf code". I am stuck and I need to know to get unstuck. Yes my dear, believe it or not, you are asking exactly that. And I will continue to ignore your posts as I did before. I know others will come to your aid but they are not teaching you. And you're not learning 🤷♂️ Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
mr-es335 Posted 5 hours ago Author Posted 5 hours ago argumentum, I live by a some very simple principles, one being, "If I do NOT know the questions to ask, how can I be expected to get the answers?" My question is, "How do I, or how to I go about discovering a resolve to how to use Code 0 to execute a 2nd script to copy the missing data? It appears that the above question is NOT the right question to ask...because I am not able to find a resolve!! I am NOT asking for an example...just an answer to my question. I HAVE tried ConsoleWrite() with no success!! mr-es335 Sentinel Music Studios
argumentum Posted 4 hours ago Posted 4 hours ago 1 hour ago, mr-es335 said: My question is, "How do I, or how to I go about discovering.... Read the help file. Try the examples. Copy the examples and change small parts until you understand them. If you have a question that is not in the help file, and not in the forum either, then I'll jump in and help. But if you don't know what basic coding tools there are, how can you formulate a question ?, or even apply common sense to your code !?. You have over 600 of these simple questions. Is time that you stop thinking of money and start understanding some basics, that will apply to all coding languages, not just AutoIt. If you do that you'll change the way you code. Because you'll change the logic in your rational thinking, because you'll remember that you can do it this or that way. But again, it'll start once you try the examples from the help file. And that is something that you should have done some 5 years ago. So no. Your code flow is wrong and you need to go to school. Go drink, smoke, play guitar or whatever you do to calm your impetuous personality, and think about what those that are harshly judging you are conveying. P.S.: Am not ignoring you ( never did ). But will not help with your code until you show some elegance, compared to your own prior style of course. Not asking for miracles. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
mr-es335 Posted 53 minutes ago Author Posted 53 minutes ago (edited) argumentum, I am actually pleased with way in which I, as you say, "code". I know that there are - for sure, better ways to do things, but what I have done works for me. Maybe to some, or even many, not elegant, but works!! What I would like to know, is that if you do not care for the way in which I do things, why do you involve yourself. Though I appreciate what you have provided for me in the past, if you do not care for what I do, then simply move on. Programming is a very, minor interest for me. I implement what I can to do the things that I need to do. As for the HelpFile...I personally do NOT find many of the examples provided there helpful at all! More than likely that may be just me...but that is way in which I see it! • Believe me, I have spent hours in the HelpFile attempting to find a resolve - with NO success whatsoever. Someone, awhile ago now, assisted me with the manner in which I employ SplashTextOn(). I use very much the same process in most of my scripts - so, to change now would be a tremendous amount of work! I am hoping someone can provide me with the questions that I need to ask myself to assist me in getting an answer to my original question. If not, then I will continue to implement manual intervention as I have been doing thus far. Anyhow, have a great day!! Edited 51 minutes ago by mr-es335 argumentum 1 mr-es335 Sentinel Music Studios
Werty Posted 7 minutes ago Posted 7 minutes ago (edited) 6 hours ago, mr-es335 said: Using MsgBox() has the text so small that I am unable to read the text. If you are not already doing it you can enlarge the windows zoom level... Right-Click the desktop and choose "Display Settings" and under "Scale and layout" change the scale level to 150% or whatever suits your needs. Also, in SciTE you can hold down CTRL on your keyboard and use the scroll wheel on your mouse to zoom in and out. Edited 4 minutes ago by Werty Some guy's script + some other guy's script = my script!
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