mr-es335 Posted November 27 Posted November 27 (edited) Good day, I have been working of a specific project over the past few months - all of which has taken me longer than anticipated...which I do sincerely believe is to be expected! At one point I also sincerely believed the project to have been successfully completed! "Surprise! Surprise!" As can be ascertained by the title, the project is entitled, "Session Show Development". Attached is an image of the "completed" project...[Image_1]. For the sake-of-simplicity, the focus of this present text will be with regards to the content as displayed in [Image_2]. With the assistance of many, in particular ioa747, I was able to resolve and issue that I was having with the ability to select incorrect paths involving the "Browse Folder" menu option. As I was investigating the initial path issues, many assisted me on various courses of action. One "solution" in particular, had to do with the employment of "global variables" - which I have always believed to be "Verboten!" However, in this particular case, it was strongly recommended that I seriously consider the employment of global variables. So, I did! However, when I was investigating the initial path issues, one of the solutions provided removed one of the global variables, which in turn affected other menu options as a result - in particular, the "Create Type_# Data" menu option. This anomaly was unforeseen on both mine and the "solution-provider's" parts, as I was only focusing on the "Browse Folder" menu option at that particular time. The Predicament! Thus, at present, I am seriously at a loss on how to resolve this present issue. To assist in a possible resolve to this present issue, I have performed the following: 1) I took the original script that employs global variables and, a) stripped down that script to the "bare essentials", and, b) renamed that script as "_WithGlobalVariables". 2) I then took the updated-and-repaired script, that employs both local and global variables and, a) stripped down that script to the "bare essentials", and, b) renamed that script as "_WithBothVariables". The titles of each of these scripts can be easily ascertained via the menu tiles as shown in [Image_3] Objectives The objective of this present issue is twofold - consisting of an "either-or" scenario, that is: 1) "Continue with employing global variables?", or 2) "Desist from employing global variables?" Attachments I have attached both of the aforementioned scripts. When perusing these scripts, please keep the following points in mind: 1) The _WithGlobalVariables: All menu options work, except when selecting a folder that is I what I refer to as "being too deep". • If you wish further information on this anomaly, please peruse the following: [Click_Me] 2) _WithBothVariables: Though I have marked the above posting as "Resolved", due to the issues that I am currently experiencing, when the script so kindly provided by ioa747 is "integrated" with the other menu options, problems do indeed arise! Again, this is no fault of ioa747, as these other menu options were not provided at the time, as I felt that such were not necessary or required. I now see that I was wrong in this assertion! As I see it.... The two key variables involved here are, 1) Global $g_SetName = ", and 2) "Global $g_SetNameWave = "". Both of these global variables get renamed to 1) $SetName and 2) $SetNameWave respectively. My initial attempt at resolve - that of changing both local variables to global, was of no success. So, I continue on... In closing... Any assistance in this matter would be greatly appreciated! As always, a sincere "thank you" for your time and attention to the above is always very much appreciated! _WithGlobalVariables.au3 _WithBothVariables.au3 Edited November 27 by mr-es335 mr-es335 Sentinel Music Studios
mr-es335 Posted November 27 Author Posted November 27 (edited) Good day, Step #1 I have taken the _BrowseForFolder function and added the _SelectWavData function and have determined the following: Case $_sCol3Row3 1st, $g_SetName= [Null] _BrowseForFolder 2nd, $g_SetName=F:\Audio\Type_1\AllMe _MoveSourceAudioData 3rd, $g_SetName=F:\Audio\Type_1\AllMe _LaunchWavFolder: Not employed! _CreateTextListing: Not employed! _LaunchTextListing: Not employed! _SelectWavData 4th, $g_SetName=F:\Audio\Type_1\AllMe Interestingly, the $g_SetName variable gets renamed to $g_SetNameWave in the _MoveSourceAudioData function. PS: I have attached the aforementioned script below... Step #2 Renamed: _BrowseForFolderSelectWavData to _BrowseForFolderSelectWavDatav2 Replaced $g_SetName with $SetName [46 results] and tested result Status: OK! Step #3 Renamed: _WithGlobalVariables to _WithGlobalVariablesv2 Replaced $g_SetName with $SetName [38 results] and tested result Status: OK! _BrowseForFolderSelectWavData.au3 Edited November 27 by mr-es335 mr-es335 Sentinel Music Studios
ioa747 Posted November 27 Posted November 27 (edited) expandcollapse popupGlobal $g_GlobalFolder = @ScriptDir & "\GlobalFolder" DirCreate($g_GlobalFolder) _Example() Func _Example() Local $sLocalFolder = @ScriptDir & "\LocalFolder" DirCreate($sLocalFolder) _OpenFolder($sLocalFolder) EndFunc ;==>_Example Func _OpenFolder($g_GlobalFolder) ConsoleWrite("$g_GlobalFolder=" & $g_GlobalFolder & @CRLF) ShellExecute($g_GlobalFolder) EndFunc ;==>_OpenFolder #cs What do I mean by this example? If you want the _OpenFolder function to go to $g_GlobalFolder, it would be better to omit the $g_GlobalFolder parameter from the _OpenFolder function. This is because the function can access the global variable directly without having to pass it as a parameter. Func _OpenFolder() ShellExecute($g_GlobalFolder) EndFunc If you keep the parameter in the _OpenFolder function, it can lead to confusion, and it can make it difficult to keep track of the variable referred to in the function, especially if $g_GlobalFolder is referred to multiple times. Alternatively, change the name of the parameter to e.g. $Folder Func _OpenFolder($Folder) ShellExecute($Folder) EndFunc #CE If this makes any sense Edited November 27 by ioa747 mr-es335 1 I know that I know nothing
ioa747 Posted November 27 Posted November 27 (edited) In real life in _WithGlobalVariables.au3 e.g. expandcollapse popupCase $_sCol3Row3 _BrowseForFolder() _LaunchWavFolder($g_SetNameWave) _CreateTextListing($g_SetNameWave) _LaunchTextListing($g_SetNameWave) ... ... ... Func _LaunchWavFolder($g_SetNameWave) ShellExecute($g_SetNameWave) ; ----------------------------------------------- Sleep(250) ; ----------------------------------------------- WinMove($g_SetNameWave, "", 970, 100, 550, 650) EndFunc ;==>_LaunchWavFolder Func _CreateTextListing($g_SetNameWave) Local $MyT1List = '' ; ----------------------------------------------- ; Assign $MyPath to $MyT1List and create the array $MyT1List = _FileListToArray($g_SetNameWave) ; Create the data file _FileCreate($g_SetNameWave & "\FileListing.txt") ; Write the array to the data file _FileWriteFromArray($g_SetNameWave & "\FileListing.txt", $MyT1List) EndFunc ;==>_CreateTextListing Func _LaunchTextListing($g_SetNameWave) ShellExecute($g_SetNameWave & "\FileListing.txt") ; ----------------------------------------------- Sleep(250) ; ----------------------------------------------- WinMove($g_SetNameWave & "\FileListing.txt", "", 400, 100, 550, 650) ; ----------------------------------------------- EndFunc ;==>_LaunchTextListing It would be clearer and easier to read. expandcollapse popupCase $_sCol3Row3 _BrowseForFolder() _LaunchWavFolder() _CreateTextListing() _LaunchTextListing() ... ... ... Func _LaunchWavFolder() ShellExecute($g_SetNameWave) ; ----------------------------------------------- Sleep(250) ; ----------------------------------------------- WinMove($g_SetNameWave, "", 970, 100, 550, 650) EndFunc ;==>_LaunchWavFolder Func _CreateTextListing() Local $MyT1List = '' ; ----------------------------------------------- ; Assign $MyPath to $MyT1List and create the array $MyT1List = _FileListToArray($g_SetNameWave) ; Create the data file _FileCreate($g_SetNameWave & "\FileListing.txt") ; Write the array to the data file _FileWriteFromArray($g_SetNameWave & "\FileListing.txt", $MyT1List) EndFunc ;==>_CreateTextListing Func _LaunchTextListing() ShellExecute($g_SetNameWave & "\FileListing.txt") ; ----------------------------------------------- Sleep(250) ; ----------------------------------------------- WinMove($g_SetNameWave & "\FileListing.txt", "", 400, 100, 550, 650) ; ----------------------------------------------- EndFunc ;==>_LaunchTextListing and it wouldn't change anything in the flow of the script Edited November 27 by ioa747 mr-es335 1 I know that I know nothing
AndrewG Posted November 27 Posted November 27 (edited) 1) The _WithGlobalVariables: All menu options work, except when selecting a folder that is I what I refer to as "being too deep". Regarding the select folder issue. Does the following example resolve the "Too deep"? Or am I not understanding your dilemma? expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Global $g_SetName = "" Global $hGUI = GUICreate("_WithGlobalVariables", 225, 165) GUISetFont(14, 800, 0, "Calibri") Global $_sCol3Row3 = GUICtrlCreateButton("Browse Folder", 10, 10, 200, 25) GUISetState(@SW_SHOW, $hGUI) Global $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $_sCol3Row3 _BrowseForFolder() EndSwitch WEnd Func _BrowseForFolder() Local $MyComputerCLSID = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" While 1 $g_SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", $MyComputerCLSID) ; ----------------------------------------------- If @error Then Local $iRetMsgBox_Notice_1 = MsgBox($MB_OKCANCEL, "NOTICE! (1)", "No valid Type_#\Set_Name folder was selected." & @CRLF & "Please select a valid Type_#\Set_Name folder", 0, $hGUI) Select Case $iRetMsgBox_Notice_1 = 2 ;Cancel button ExitLoop Case $iRetMsgBox_Notice_1 = 1 ;OK button ContinueLoop EndSelect EndIf ; ----------------------------------------------- Local $_aGetType = StringSplit($g_SetName, "\") ; ----------------------------------------------- Select Case $_aGetType[0] < 3 Or $_aGetType[0] > 3 Local $iRetMsgBox_Notice_2 = MsgBox($MB_OKCANCEL, "NOTICE! (2)", "You must select a valid Type_#\Set_Name folder...", 0, $hGUI) Select Case $iRetMsgBox_Notice_2 = 2 ;Cancel button ExitLoop Case $iRetMsgBox_Notice_2 = 1 ;OK button ContinueLoop EndSelect Case $_aGetType[3] = "Type_1" ;~ _MoveSourceAudioData($g_SetName) MsgBox(0, "Message", "Selected folder: " & $_aGetType[3], 0, $hGUI) ExitLoop Case $_aGetType[3] = "Type_2" ;~ _MoveSourceAudioData($g_SetName) MsgBox(0, "Message", "Selected folder: " & $_aGetType[3], 0, $hGUI) ExitLoop EndSelect WEnd Return EndFunc ;==>_BrowseForFolder Edited November 28 by AndrewG
mr-es335 Posted November 28 Author Posted November 28 Andrew, Thanks for the above...but, would you be so kind as to move this comment to...[Click_Me] My pea-sized intellect does not permit me to stray for the job-at-hand. I am already both overwhelmed and confused enough over what I have to absorb here at the moment. You have been a great help to me in the past and I would never want to offend or dissuade you in any way whatsoever. Thank you for your understanding...appreciated. mr-es335 Sentinel Music Studios
mr-es335 Posted November 28 Author Posted November 28 ioa747, Example #1: $g_GlobalFolder Yes, I do believe that I "get it"! Why pass a global variable as a parameter when that parameter already exists globally? Duh! As you noted, "...If you keep the parameter in the _OpenFolder function, it can lead to confusion,..." So true!! Example #2: Yes! As with Example #1, no need to pass global variables!! And yes...the second example is indeed, much easier to read. And by-the-way, why is it that programmers have a seeming propensity for getting sick? Because, as programmers, they are alwyas getting "head codes"!! ioa747 1 mr-es335 Sentinel Music Studios
AndrewG Posted November 28 Posted November 28 54 minutes ago, mr-es335 said: Andrew, Thanks for the above...but, would you be so kind as to move this comment to...[Click_Me] My pea-sized intellect does not permit me to stray for the job-at-hand. I am already both overwhelmed and confused enough over what I have to absorb here at the moment. You have been a great help to me in the past and I would never want to offend or dissuade you in any way whatsoever. Thank you for your understanding...appreciated. Mr es335, Very understandable. However; you do not have a pea-sized intellect. Get rid of that negative self-deprecation, as you are only making it harder on yourself with that thinking. We all want to run, but we all have to learn to walk first. Take short breaks. Do something else like play an ES335. Programming does seem to be new to you. Programming is hard. The first programming language anyone learns is usually the hardest. Again, one has to learn how to walk before one can run, and we all want to run. As you already know; Programs get complicated fast. Your mind will adjust if you stay with it long enough. AutoIt is probably the easiest dynamic programming language to learn. Learning to write programs does take time. A lot of time. A very large investment of time spent coding is required to become really good at coding. I have days where I just suck at it. So I smile, I take a break, and come back to it. The devil smiles at us all, all anyone can do is smile back. ioa747 and mr-es335 1 1
mr-es335 Posted November 28 Author Posted November 28 Good day, I would like to share with you my current progress...see attached... To Do's.txt mr-es335 Sentinel Music Studios
mr-es335 Posted November 28 Author Posted November 28 Good day, I am really at a loss on how to resolve this anomaly! The problem appears to be that _SelectWavData is not receiving $SetName! This is how I observe things at the moment: • $SetName should equal, at least for this test: F:\Audio\Type_1\AllMe 1) _BrowseForFolder sends two arguments to _MoveSourceAudioData 2) _MoveSourceAudioData receives these arguments as $SetName 3) _MoveSourceAudioData assigns $g_SetNameWave to $SetName 4) _SelectWavData($SetName) returns a null value I have attached my testing script... Any assistance in this matter would be greatly appreciated! _BrowseForFolderSelectWavDataV3.au3 mr-es335 Sentinel Music Studios
mr-es335 Posted November 28 Author Posted November 28 (edited) Andrew, Going to continue this on the other postings...[Click_Me] Edited November 28 by mr-es335 mr-es335 Sentinel Music Studios
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