mr-es335 Posted 21 hours ago Share Posted 21 hours ago (edited) Good day, I have two identical scripts, the only exception being 1) the source data path is being manually entered [_EnterSetName()], and 2) the source data path is being browsed for [_BrowseForFolder()]. The purpose of having both, is 1) the source data path is being manually entered is for those situations where the source data path does not yet exist, and 2) the source data path is being browsed for is for an existing source data path. I do hope that this makes sense? The issue is that the first works and the second does not! Yet, the ONLY DIFFERENCE is in the first Function...which is either _EnterSetName() or _BrowseForFolder() I have added extra lines to _EnterSetName() to make the two scripts the same in length. I have also added MsgBox portions where needed. Here is the script employing _EnterSetName()... expandcollapse popup; ----------------------------------------------- #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $_MasterEdlFile = "" ; This global variable must always be enabled! ; ----------------- Global $_sMasterType1Edl = "Type1.edl" Global $_sMasterType2Edl = "Type2.edl" Global $_sMasterType3Edl = "Type3.edl" Global $_sMasterType4Edl = "Type4.edl" ; ----------------- Global $g_SetName = "" ; ----------------------------------------------- _EnterSetName() ; ----------------------------------------------- Func _EnterSetName() $g_SetName = InputBox("Notice!", "Enter the Type_# Set_Name...", "", " M", 200, 130) ; ----------------- If @error Then MsgBox($MB_ICONWARNING, "Notice!", "The operation was cancelled. Exiting!") Exit Else ;Filler ;Filler ;Filler ;Filler ;Filler ;Filler ;Filler ;Filler ;Filler MsgBox(0, "", "#1: _EnterSetName(): " & $g_SetName) ; NO 1!!!! _SelectWavData($g_SetName) EndIf ;Filler ;Filler EndFunc ;==>_EnterSetName ; ----------------------------------------------- Func _SelectWavData($g_SetName) Local $_ConfirmCreate = MsgBox($MB_YESNO, "Notice!", "Create " & StringMid($g_SetName, 10, 6) & " Session Data from .wav file data?") MsgBox(0, "", "#2a: _SelectWavData(): " & $g_SetName) ; ----------------------------------------------- If $_ConfirmCreate = $IDYES Then MsgBox(0, "", "#2b: _SelectWavData(): " & $g_SetName) Local $_WavFiles = _FileOpenDialog() MsgBox(0, "", "#2c: _SelectWavData(): " & $g_SetName) Local $_DestFolder = _FileSelectFolder() Local $_sWavFolder = $_WavFiles[1] ; Contains only a path, no matter if the user has selected one or more files. ; ----------------------------------------------- For $i = 2 To $_WavFiles[0] ; First file name in element 2, and so on. Local $_WavFileName = $_sWavFolder & "\" & $_WavFiles[$i] Local $_WavBaseName = StringTrimRight($_WavFiles[$i], 4) ; ----------------- Local $_NewEdlFile = $_DestFolder & "\" & $_WavBaseName & ".edl" ; ----------------- FileCopy($_MasterEdlFile, $_NewEdlFile, $FC_NOOVERWRITE) Next ; ----------------- MsgBox($MB_ICONINFORMATION, "Success!", "The " & StringMid($g_SetName, 10, 6) & " Sesson .edl data file(s) have been successfully created!") ; ----------------------------------------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Cancelled!", "The operation was cancelled by the user.") Exit EndIf EndFunc ;==>_SelectWavData ; ----------------------------------------------- Func _FileOpenDialog() While 1 MsgBox(0, "", "#3: _FileOpenDialog(): " & $g_SetName) Local $_sMessage = "Please select the required source .wav file data..." Local $_ConfirmOpenDialog = MsgBox($MB_YESNO, "Notice!", $_sMessage) ; ----------------------------------------------- If $_ConfirmOpenDialog = $IDYES Then Local $_sFileOpenDialog = FileOpenDialog($_sMessage, $g_SetName & "\wav", "Wave Data (*.wav)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONINFORMATION, "Notice!", "No source .wav file data was selected!" & @CRLF & "You must select at least one source .wav file!") ContinueLoop ; While 1 EndIf ; ----------------------------------------------- Local $_WavFiles = StringSplit($_sFileOpenDialog, "|") ; ----------------------------------------------- If $_WavFiles[0] = 1 Then ; If only one file was selected by the user. Local $iPos_LastBackslash = StringInStr($_WavFiles[1], "\", 0, -1) ; -1 starts from the right (+++). ; ----------------------------------------------- ReDim $_WavFiles[3] $_WavFiles[2] = StringMid($_WavFiles[1], $iPos_LastBackslash + 1) ; The file name. $_WavFiles[1] = StringLeft($_WavFiles[1], $iPos_LastBackslash - 1) ; The path without last backslash. $_WavFiles[0] = 2 EndIf ; ----------------- Return $_WavFiles ; ----------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled by the user. Exiting!") Exit EndIf WEnd EndFunc ;==>_FileOpenDialog ; ----------------------------------------------- Func _FileSelectFolder() While 1 Local $_Message = "Please select the Destination folder for the Session .edl file(s)..." Local $_ConfirmFileSelect = MsgBox($MB_YESNO, "Notice!", $_Message) ; ----------------------------------------------- If $_ConfirmFileSelect = $IDYES Then Local $_DestFolder = FileSelectFolder($_Message, $g_SetName) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONINFORMATION, "Notice!", "No destination Session .edl folder was selected!" & @CRLF & "You must select a destination Session .edl folder!") ContinueLoop ; While 1 ; ----------------------------------------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_1" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType1Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_2" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType2Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_3" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType3Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_4" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType4Edl ; ----------------- Else MsgBox($MB_ICONERROR, "Notice!", "The " & $_MasterEdlFile & " Session .edl file was not found.") ContinueLoop ; While 1 EndIf ; ----------------- Return $_DestFolder ; ----------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled by the user. Exiting!") Exit EndIf WEnd EndFunc ;==>_FileSelectFolder ; ----------------------------------------------- ...and...here is the script employing _BrowseForFolder()... expandcollapse popup; ----------------------------------------------- #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $_MasterEdlFile = "" ; This global variable must always be enabled! ; ----------------- Global $_sMasterType1Edl = "Type1.edl" Global $_sMasterType2Edl = "Type2.edl" Global $_sMasterType3Edl = "Type3.edl" Global $_sMasterType4Edl = "Type4.edl" ; ----------------- Global $g_SetName = "" ; ----------------------------------------------- _BrowseForFolder() ; ----------------------------------------------- Func _BrowseForFolder() While 1 Local $g_SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "") ; ----------------------------------------------- If @error Then MsgBox($MB_TOPMOST, "", "No valid Type_#\Set_Name folder was selected." & @CRLF & "Please select a valid Type_#\Set_Name folder") ContinueLoop EndIf ; ----------------------------------------------- Local $_aGetType = StringSplit($g_SetName, "\") ; ----------------------------------------------- Select Case $_aGetType[0] < 3 MsgBox($MB_TOPMOST, "NOTICE!", "You must select a valid Type_#\Set_Name folder...") ContinueLoop Case $_aGetType[3] = "Type_1" MsgBox(0, "", "#1: _BrowseForFolder(): " & $g_SetName) ; NO 1!!!! _SelectWavData($g_SetName) ExitLoop EndSelect WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Func _SelectWavData($g_SetName) Local $_ConfirmCreate = MsgBox($MB_YESNO, "Notice!", "Create " & StringMid($g_SetName, 10, 6) & " Session Data from .wav file data?") MsgBox(0, "", "#2a: _SelectWavData(): " & $g_SetName) ; ----------------------------------------------- If $_ConfirmCreate = $IDYES Then MsgBox(0, "", "#2b: _SelectWavData(): " & $g_SetName) Local $_WavFiles = _FileOpenDialog() MsgBox(0, "", "#2c: _SelectWavData(): " & $g_SetName) Local $_DestFolder = _FileSelectFolder() Local $_sWavFolder = $_WavFiles[1] ; Contains only a path, no matter if the user has selected one or more files. ; ----------------------------------------------- For $i = 2 To $_WavFiles[0] ; First file name in element 2, and so on. Local $_WavFileName = $_sWavFolder & "\" & $_WavFiles[$i] Local $_WavBaseName = StringTrimRight($_WavFiles[$i], 4) ; ----------------- Local $_NewEdlFile = $_DestFolder & "\" & $_WavBaseName & ".edl" ; ----------------- FileCopy($_MasterEdlFile, $_NewEdlFile, $FC_NOOVERWRITE) Next ; ----------------- MsgBox($MB_ICONINFORMATION, "Success!", "The " & StringMid($g_SetName, 10, 6) & " Sesson .edl data file(s) have been successfully created!") ; ----------------------------------------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Cancelled!", "The operation was cancelled by the user.") Exit EndIf EndFunc ;==>_SelectWavData ; ----------------------------------------------- Func _FileOpenDialog() While 1 MsgBox(0, "", "#3: _FileOpenDialog(): " & $g_SetName) Local $_sMessage = "Please select the required source .wav file data..." Local $_ConfirmOpenDialog = MsgBox($MB_YESNO, "Notice!", $_sMessage) ; ----------------------------------------------- If $_ConfirmOpenDialog = $IDYES Then Local $_sFileOpenDialog = FileOpenDialog($_sMessage, $g_SetName & "\wav", "Wave Data (*.wav)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT)) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONINFORMATION, "Notice!", "No source .wav file data was selected!" & @CRLF & "You must select at least one source .wav file!") ContinueLoop ; While 1 EndIf ; ----------------------------------------------- Local $_WavFiles = StringSplit($_sFileOpenDialog, "|") ; ----------------------------------------------- If $_WavFiles[0] = 1 Then ; If only one file was selected by the user. Local $iPos_LastBackslash = StringInStr($_WavFiles[1], "\", 0, -1) ; -1 starts from the right (+++). ; ----------------------------------------------- ReDim $_WavFiles[3] $_WavFiles[2] = StringMid($_WavFiles[1], $iPos_LastBackslash + 1) ; The file name. $_WavFiles[1] = StringLeft($_WavFiles[1], $iPos_LastBackslash - 1) ; The path without last backslash. $_WavFiles[0] = 2 EndIf ; ----------------- Return $_WavFiles ; ----------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled by the user. Exiting!") Exit EndIf WEnd EndFunc ;==>_FileOpenDialog ; ----------------------------------------------- Func _FileSelectFolder() While 1 Local $_Message = "Please select the Destination folder for the Session .edl file(s)..." Local $_ConfirmFileSelect = MsgBox($MB_YESNO, "Notice!", $_Message) ; ----------------------------------------------- If $_ConfirmFileSelect = $IDYES Then Local $_DestFolder = FileSelectFolder($_Message, $g_SetName) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONINFORMATION, "Notice!", "No destination Session .edl folder was selected!" & @CRLF & "You must select a destination Session .edl folder!") ContinueLoop ; While 1 ; ----------------------------------------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_1" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType1Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_2" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType2Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_3" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType3Edl ; ----------------- ElseIf StringMid($g_SetName, 10, 6) = "Type_4" Then $_MasterEdlFile = "G:\Session_Master\Show\Session_Data\" & $_sMasterType4Edl ; ----------------- Else MsgBox($MB_ICONERROR, "Notice!", "The " & $_MasterEdlFile & " Session .edl file was not found.") ContinueLoop ; While 1 EndIf ; ----------------- Return $_DestFolder ; ----------------- Else ; $IDNO MsgBox($MB_ICONINFORMATION, "Notice!", "The operation was cancelled by the user. Exiting!") Exit EndIf WEnd EndFunc ;==>_FileSelectFolder ; ----------------------------------------------- The Main Issue In the _EnterSetName() script, the Global variable $g_SetName is passing the correct source path, whilst in the _BrowseForFolder() script, the Global variable $g_SetName IS NOT passing the correct source path. And yet, from what I can observe, the scripts are identical!?! Any assistance in this matter would be greatly appreciated! Thank you for your time! Appreciated! Important Note As an aside, the current combination of _EnterSetName() amd _SelectWavData...so the first script, appears to work as expected. Therefore, it is the second that appears to be the primary issues. The question is "Why?" Thanks! Â Â Â Edited 14 hours ago by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted 15 hours ago Share Posted 15 hours ago lines 48 and 70 they are not the same I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted 15 hours ago Author Share Posted 15 hours ago (edited) In the above or in the Zips. I made a mistake in the Zips and though that I had correct that mistake in the above examples. Here are the updated Zips... • Man, this is "driving me crazy!!" Testing.zip Edited 15 hours ago by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted 15 hours ago Share Posted 15 hours ago line 70 they are not the same I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted 15 hours ago Author Share Posted 15 hours ago (edited) ...they look the same to me? Â Â Â Edited 15 hours ago by mr-es335 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted 15 hours ago Share Posted 15 hours ago it's because you didn't extract them from the zip file I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted 14 hours ago Author Share Posted 14 hours ago (edited) Yes! However, I did update the Zips...see the above posting! In the previous Zips, I have it as line 47 as being different... Note:: I have remove the previous Zips! Edited 14 hours ago by mr-es335 Remove previous Zips! Sorry! mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted 14 hours ago Share Posted 14 hours ago (edited) Put a ConsoleWrite below the _EnterSetName() in the _EnterSetName.au3 like: _EnterSetName() ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) and Put a ConsoleWrite below the _BrowseForFolder() in the _BrowseForFolder.au3 like: _BrowseForFolder() ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) and check if there is any difference Tip: avoid the parameters of a function having the same name as global variables in the definition during the call there is no problem in function Func _SelectWavData($g_SetName) change $g_SetName to $SetName so that the parameter does not have synonyms with the global variable  Edited 14 hours ago by ioa747 corrected _BrowseForFolder I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted 13 hours ago Author Share Posted 13 hours ago Like this? Func _EnterSetName() Â Â Â ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) Func _BrowseForFolder() Â Â Â ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) If so, the results are: $g_SetName= Â Â mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted 13 hours ago Share Posted 13 hours ago (edited) remove the Local in _BrowseForFolder.au3 in line 21 Local $g_SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "") Edited 13 hours ago by ioa747 I know that I know nothing Link to comment Share on other sites More sharing options...
Solution ioa747 Posted 13 hours ago Solution Share Posted 13 hours ago 7 minutes ago, mr-es335 said: Like this? No  like this ; _BrowseForFolder.au3 ; ----------------------------------------------- #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $_MasterEdlFile = "" ; This global variable must always be enabled! ; ----------------- Global $_sMasterType1Edl = "Type1.edl" Global $_sMasterType2Edl = "Type2.edl" Global $_sMasterType3Edl = "Type3.edl" Global $_sMasterType4Edl = "Type4.edl" ; ----------------- Global $g_SetName = "" ; ----------------------------------------------- _BrowseForFolder() ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) ; ----------------------------------------------- ... ... and this ; _EnterSetName.au3 ; ----------------------------------------------- #include <FileConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Global $_MasterEdlFile = "" ; This global variable must always be enabled! ; ----------------- Global $_sMasterType1Edl = "Type1.edl" Global $_sMasterType2Edl = "Type2.edl" Global $_sMasterType3Edl = "Type3.edl" Global $_sMasterType4Edl = "Type4.edl" ; ----------------- Global $g_SetName = "" ; ----------------------------------------------- _EnterSetName() ConsoleWrite("$g_SetName=" & $g_SetName & @CRLF) ; ----------------------------------------------- ... ...  mr-es335 1 I know that I know nothing Link to comment Share on other sites More sharing options...
mr-es335 Posted 11 hours ago Author Share Posted 11 hours ago ioa747, You have NO idea how grateful I am! All because of a five character word...I have spend the better part of ten+hours on this endeavour!! It would "appear" ...[...and please correct me if I wrong here...though I believe NOT...]...In the original Function, though a Global variable was declared, I assigned that Global variable as Local! what a "DuFuss!" Anyhow...we move on and hopefully...learn from our mistakes!! Thanks again, ioa747...you have come to my rescue again! Appreciated! ioa747 1 mr-es335 Sentinel Music Studios Link to comment Share on other sites More sharing options...
ioa747 Posted 11 hours ago Share Posted 11 hours ago this is also the reason we put $g_ in front, or we don't use it as a parameter in the function definition so that it hits the eye that it is global $g_SetName glad i helped I know that I know nothing 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