mr-es335 Posted December 4 Posted December 4 Good day, I would really appreciate some assistance with regards to a portion of a script that was provided for me, and of which, I have NO IDEA what is going on or how to "ConsoleWrite" this protion of script? Any assistance|clarification in this matter would be greatly appreciated! Here is the script: ; ----------------------------------------------- #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _BrowseForFolder() ; ----------------------------------------------- Func _BrowseForFolder() While 1 Local $SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio") ; ----------------------------------------------- Local $_aType = StringSplit($SetName, "\") If $_aType[0] = 4 Then If $_aType[2] = "Audio" And StringRegExp($_aType[3], "Type_[1-4]") Then Local $_sTypeFolder = $_aType[1] & "\" & $_aType[2] & "\" & $_aType[3] Local $_sSetName = $_aType[4] _MoveSourceAudioData($_sTypeFolder, $_sSetName) ExitLoop EndIf EndIf ; ----------------------------------------------- MsgBox($MB_TOPMOST, "Notice!", "Invalid [F:\Audio\Type_#\Set_Name] folder selected...") WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Func _MoveSourceAudioData($_sTypeFolder, $_sSetName) MsgBox($MB_TOPMOST, "", "Inside of _MoveSourceAudioData...with: " & @CRLF & $_sTypeFolder & "\" & $_sSetName & "\wav") EndFunc ;==>_FunctionType_1 ; ----------------------------------------------- ...in particular, this line: If $_aType[2] = "Audio" And StringRegExp($_aType[3], "Type_[1-4]") Then The following paths are what I am deploying for this example: F:\Audio [The default "root" path] F:\Audio\Type_1\AllMe F:\Audio\Type_2\AllMe F:\Audio\Type_2\A\AllMe F:\Audio\Type_3\AllMe F:\Audio\Type_4\AllMe mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 (edited) 18 minutes ago, mr-es335 said: F:\Audio\Type_2\A\AllMe Now he gets everything except this. This path, be it acceptable or unacceptable? Edited December 4 by ioa747 I know that I know nothing
mr-es335 Posted December 4 Author Posted December 4 ios747, The path "F:\Audio\Type_2\A\AllMe" is unacceptable... mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 then everything looks good, what's the issue I know that I know nothing
mr-es335 Posted December 4 Author Posted December 4 (edited) ioa747, Firstly, I am simply attempting to ascertain what is going on i the above script...so that I may learn from it...again, especially with regards to "StringRegExp($_aType[3], "Type_[1-4]")"... Secondly, I updated this line: If $_aType[2] = "Audio" And StringRegExp($_aType[3], "Type_[1-4]") Then ...to this... If $_aType[3] = $_aType[3] And StringRegExp($_aType[3], "Type_[1-4]") Then ...as "Audio" has already been predetermined... I also updated this... ; ----------------------------------------------- Func _MoveSourceAudioData($_sTypeFolder, $_sSetName) MsgBox($MB_TOPMOST, "", "Inside of _MoveSourceAudioData...with: " & @CRLF & $_sTypeFolder & "\" & $_sSetName & "\wav") EndFunc ;==>_FunctionType_1 ; ----------------------------------------------- ...to this... Func _MoveSourceAudioData($_sTypeFolder, $_sSetName) ConsoleWrite($_sTypeFolder & @CRLF) ConsoleWrite($_sSetName & @CRLF) MsgBox($MB_TOPMOST, "", "Inside of _MoveSourceAudioData...with: " & @CRLF & $_sTypeFolder & "\" & $_sSetName & "\wav") EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- Edited December 4 by mr-es335 mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 (edited) If $_aType[2] = "Audio" And StringRegExp($_aType[3], "Type_[1-4]") Then What does the line mean? if we have the path: F:\Audio\Type_2\AllMe then is $_aType[0] = 4 $_aType[1] = F: $_aType[2] = Audio $_aType[3] = Type_2 $_aType[4] = AllMe If $_aType[2] = "Audio" And $_aType[3] = Type_ and a number from 1 to 4 Then Edit: I also updated this... ...to this... If $_aType[3] = $_aType[3] And StringRegExp($_aType[3], "Type_[1-4]") Then What does the line mean? Edited December 4 by ioa747 mr-es335 1 I know that I know nothing
mr-es335 Posted December 4 Author Posted December 4 iao747, Okay! May I ask how do you ConsoleWrite "StringRegExp($_aType[3], "Type_[1-4]") "? mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 ; ----------------------------------------------- #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _BrowseForFolder() ; ----------------------------------------------- Func _BrowseForFolder() While 1 Local $SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio") ; ----------------------------------------------- Local $_aType = StringSplit($SetName, "\") If $_aType[0] = 4 Then ConsoleWrite("[0]=" & $_aType[0] & @CRLF) ConsoleWrite("[1]=" & $_aType[1] & @CRLF) ConsoleWrite("[2]=" & $_aType[2] & @CRLF) ConsoleWrite("[3]=" & $_aType[3] & @CRLF) ConsoleWrite("[4]=" & $_aType[4] & @CRLF) If $_aType[2] = "Audio" And StringRegExp($_aType[3], "Type_[1-4]") Then Local $_sTypeFolder = $_aType[1] & "\" & $_aType[2] & "\" & $_aType[3] & "\" & $_aType[4] _MoveSourceAudioData($_sTypeFolder) ExitLoop EndIf EndIf ; ----------------------------------------------- MsgBox($MB_TOPMOST, "Notice!", "Invalid [F:\Audio\Type_#\Set_Name] folder selected...") WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Func _MoveSourceAudioData($sFolderPath) ConsoleWrite("Inside of _MoveSourceAudioData...with: " & $sFolderPath & "\wav" & @CRLF) EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- mr-es335 1 I know that I know nothing
mr-es335 Posted December 4 Author Posted December 4 ioa7477, Thanks...will "dissect" the above... I forgot that you had also provided this little snippet... ; ----------------------------------------------- #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _BrowseForFolder() ; ----------------------------------------------- Func _BrowseForFolder() While 1 Local $_sSetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\") Local $iFileExists = FileExists($_sSetName & "\wav") ; ----------------------------------------------- If StringRegExp($_sSetName & "\", "\\Type_[1-4]\\") Then ; ------------- If $iFileExists Then _MoveSourceAudioData($_sSetName) ExitLoop EndIf Else MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...") EndIf WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Func _MoveSourceAudioData($_sSetName) ConsoleWrite($_sSetName & @CRLF) MsgBox($MB_TOPMOST, "", "Inside of _MoveSourceAudioData...with: " & "\" & $_sSetName & "\wav") EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 (edited) $test = "Type_1" ConsoleWrite("--> " & StringRegExp($test, "Type_[1-4]") & @CRLF) $test = "Type_10" ConsoleWrite("--> " & StringRegExp($test, "Type_[1-4]") & @CRLF) $test = "Type_5" ConsoleWrite("--> " & StringRegExp($test, "Type_[1-4]") & @CRLF) $test = "Type_10" ConsoleWrite("--> " & StringRegExp($test, "Type_[1-4]$") & @CRLF) Edited December 4 by ioa747 mr-es335 1 I know that I know nothing
mr-es335 Posted December 4 Author Posted December 4 (edited) ioa747, Such examples are "extremely helpful" and should be made available in the HelpFile [...I have developed my own HelpFile of such snippets...] Also, I want to extend a "Thank You!" to you, for assisting me in getting around the "Global Variable" employment debacle. The above "_BrowseForFolder" function consists of four supporting Functions...all of which now employ local variables! PS: I have now marked the following as the solution...[FileSelectFolder Issues] ...the only modifications were with regards to the removal of all "Global Variables"... Here is the "Final Solution" then... ; ----------------------------------------------- ; https://www.autoitscript.com/forum/topic/212495-fileselectfolder-issues/?do=findComment&comment=1538829 ; ----------------------------------------------- #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _BrowseForFolder() ; ----------------------------------------------- Func _BrowseForFolder() While 1 Local $_sSetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\") ; "F:\Audio\" ConsoleWrite("$_sSetName=" & $_sSetName & @CRLF) ; ----------------------------------------------- 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 ; ----------------------------------------------- If StringRegExp($_sSetName & "\", "\\Type_[1-2]\\") Then ConsoleWrite("$_aGetType=" & $_sSetName & @CRLF) _MoveSourceAudioData($_sSetName) ExitLoop Else MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...") EndIf WEnd EndFunc ;==>_BrowseForFolder ; ----------------------------------------------- Func _MoveSourceAudioData($_sSetName) MsgBox($MB_TOPMOST, "NOTICE!", "Made it to _MoveSourceAudioData...with..." & @CRLF & " ..." & $_sSetName & "...as the \wav path!") EndFunc ;==>_MoveSourceAudioData ; ----------------------------------------------- Edited December 4 by mr-es335 Errors in script example mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 (edited) Func _MoveSourceAudioData($sFolderPath) If FileExists($sFolderPath & "\wav") Then MsgBox($MB_TOPMOST, "NOTICE!", "Made it to _MoveSourceAudioData...with..." & @CRLF & " ..." & $sFolderPath & "...as the \wav path!") Else MsgBox($MB_TOPMOST, "NOTICE!", "... the \wav folder is missing in" & @CRLF & $sFolderPath) EndIf EndFunc ;==>_MoveSourceAudioData Edited December 4 by ioa747 mr-es335 1 I know that I know nothing
mr-es335 Posted December 4 Author Posted December 4 6 minutes ago, ioa747 said: Func _MoveSourceAudioData($_sSetName) ; Corrected variable If FileExists($g_SetName & "\wav") Then MsgBox($MB_TOPMOST, "NOTICE!", "Made it to _MoveSourceAudioData...with..." & @CRLF & " ..." & $_sSetName & "...as the \wav path!") ; Corrected variable Else MsgBox($MB_TOPMOST, "NOTICE!", "... the \wav path! is missing in" & @CRLF & $_sSetName) ; Corrected variable EndIf EndFunc ;==>_MoveSourceAudioData mr-es335 Sentinel Music Studios
ioa747 Posted December 4 Posted December 4 (edited) I updated it above. The main point is to check that is a wav folder there. since this is not certain Edited December 4 by ioa747 I know that I know nothing
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