mr-es335 Posted October 23, 2024 Posted October 23, 2024 Good day, When I launch the following script within SciTE...all works as it should. However, when I launch the same script outside of SciTE - what I refer to as "standalone", I receive the attached error... Here is the script: expandcollapse popup; ----------------------------------------------- #include <Array.au3> #include <AutoItConstants.au3> #include <File.au3> #include <FileConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- Local $hGUI = GUICreate("Session Development Main Menu", 215, 75) GUISetFont(13, 800, 0, "Calibri") ; ----------------------------------------------- ; COLUMN 4 BUTTONS Local $_sSrcPath4a = GUICtrlCreateButton("Exit", 10, 10, 200, 25) Local $_sSrcPath4b = GUICtrlCreateButton("Cleanup Sess_Undo", 10, 40, 200, 25) ; ----------------------------------------------- GUISetState(@SW_SHOW, $hGUI) ; ----------------------------------------------- While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $_sSrcPath4a _Exit() Case $_sSrcPath4b _CleanUpSessUndo() EndSwitch WEnd ; ----------------------------------------------- Func _Exit() Exit EndFunc ;==>_Exit ; ----------------------------------------------- Func _CleanUpSessUndo() Local $confirmCreate = MsgBox(4, "NOTICE!", "Select the Session folder to cleanup...") Local $_sSrcPath1 = "Session_Undo" ; ----------------- If $confirmCreate = 6 Then ; If "Yes" is selected ; Prompt the user to select the source folder containing the .wav file data Local $sourceMessage = "Select Source folder..." ;Local $sourceFolder = FileSelectFolder($sourceMessage, "F:\Audio\Type_1") Local $sourceFolder = FileSelectFolder($sourceMessage, "") ; ----------------- If @error Then MsgBox($MB_ICONERROR, "Error", "No folder selected. Exiting.") Return EndIf EndIf ; ----------------------------------------------- Local $_sSrcPath2 = _FileListToArrayRec($sourceFolder, $_sSrcPath1, $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ; ----------------- For $i = 1 To $_sSrcPath2[0] FileDelete($_sSrcPath2[$i] & "\*.u*") Next EndFunc ;==>_CleanUpSessUndo ; ----------------------------------------------- Line 52 appears to be the issue here: Local $_sSrcPath2 = _FileListToArrayRec($sourceFolder, $_sSrcPath1, $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) Any assistance in this matter would be greatly appreciated! I am at a complete loss here!! mr-es335 Sentinel Music Studios
Solution ioa747 Posted October 23, 2024 Solution Posted October 23, 2024 that means it goes to line 52 and doesn't know what $sourceFolder is. and this happens because $confirmCreate is not 6 (otherwise it would know) mr-es335 1 I know that I know nothing
mr-es335 Posted October 23, 2024 Author Posted October 23, 2024 Hello, This is really helpful!! I do not disagree with you in the least...but why does the script appear to "work" inside SciTE - and not work outside of SciTE? mr-es335 Sentinel Music Studios
mr-es335 Posted October 23, 2024 Author Posted October 23, 2024 Good day, By golly...I do believe that I have "fixed it"!!! Func _CleanUpSessUndo() Local $confirmCreate = MsgBox(4, "NOTICE!", "Select the Session folder to cleanup...") Local $_sSrcPath1 = "Session_Undo" ; ----------------- If $confirmCreate = 6 Then ; If "Yes" is selected ; Prompt the user to select the source folder containing the .wav file data Local $sourceMessage = "Select Source folder..." ;Local $sourceFolder = FileSelectFolder($sourceMessage, "F:\Audio\Type_1") Local $sourceFolder = FileSelectFolder($sourceMessage, "") Local $_sSrcPath2 = _FileListToArrayRec($sourceFolder, $_sSrcPath1, $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ; ----------------- For $i = 1 To $_sSrcPath2[0] FileDelete($_sSrcPath2[$i] & "\*.u*") Next ; ----------------- If @error Then MsgBox($MB_ICONERROR, "Error", "No folder selected. Exiting.") Return EndIf EndIf ; ----------------------------------------------- EndFunc ;==>_CleanUpSessUndo ; ----------------------------------------------- Thanks to ioa747...he "...got me thinkin'..." mr-es335 Sentinel Music Studios
ioa747 Posted October 24, 2024 Posted October 24, 2024 (edited) glad you solved the riddle, but you still have a couple of issues 1. put If @error Then in its place, where it is now it doesn't offer anything 2. What if it doesn't find $_sSrcPath1 ? You need one there too If @error Then What exactly is _FileListToArrayRec doing here? how many "Session_Undo" folders does $sourceFolder have? wouldn't it be better for _FileListToArrayRec to directly find the files to delete? Edited October 24, 2024 by ioa747 correction I know that I know nothing
mr-es335 Posted October 24, 2024 Author Posted October 24, 2024 (edited) ioa747m This is the initial path to the Session_Undo folder: F:\Audio\Type_#\ArtistName\edl\Session_Undo • There are 4 Type_# folders • There could be a single Type_# sub-folder, or there could be fifty!! It all depends on the content of the Type_# folder. • For example: F:\Audio\Type_1\AndreaBochelli\edl\Session_Undo Q: "What exactly is _FileListToArrayRec doing here?" A: Scanning all sub-folders for *.u* data files, which will then be deleted. Hope this helps? Edited October 24, 2024 by mr-es335 ioa747 1 mr-es335 Sentinel Music Studios
mr-es335 Posted October 24, 2024 Author Posted October 24, 2024 (edited) ioa747, How is this? ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _CleanUpSessUndo() ; ----------------------------------------------- Func _CleanUpSessUndo() ; Source Data Local $_sSrcPath1 = MsgBox($MB_OK, "NOTICE!", "Select the Session folder to cleanup...") ; Should this line be error checked?? Local $_sSrcPath2 = "Session_Undo" ; ----------------------------------------------- If $_sSrcPath1 = 1 Then ; Source Data Local $_SourceMessage = "Select Source folder..." Local $_SourceFolder = FileSelectFolder($_SourceMessage, "") Local $_sSrcPath3 = _FileListToArrayRec($_SourceFolder, $_sSrcPath2, $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ; ----------------------------------------------- If @error Then MsgBox($MB_ICONERROR, "NOTICE!", "No folder selected...exiting...") Return Else For $i = 1 To $_sSrcPath3[0] FileDelete($_sSrcPath3[$i] & "\*.u*") Next EndIf EndIf EndFunc ;==>_CleanUpSessUndo ; ----------------------------------------------- Edited October 24, 2024 by mr-es335 mr-es335 Sentinel Music Studios
mr-es335 Posted October 24, 2024 Author Posted October 24, 2024 (edited) ioa747, ...or this... ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _CleanUpSessUndo() ; ----------------------------------------------- Func _CleanUpSessUndo() Local $_sSrcPath1a = "Select the Session folder to cleanup..." Local $_sSrcPath1b = "Session_Undo" Local $_sFileSelectFolder = FileSelectFolder($_sSrcPath1a, "") ; ----------------------------------------------- If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Else MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $_sFileSelectFolder) Local $_sSrcPath2 = _FileListToArrayRec($_sFileSelectFolder, $_sSrcPath1b, $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ; ----------------------------------------------- For $i = 1 To $_sSrcPath2[0] FileDelete($_sSrcPath2[$i] & "\*.u*") Next EndIf EndFunc ;==>_CleanUpSessUndo ; ----------------------------------------------- Am I beginning "...to see the light?..." Edited October 24, 2024 by mr-es335 mr-es335 Sentinel Music Studios
mr-es335 Posted October 24, 2024 Author Posted October 24, 2024 (edited) ioa747, Is this script "safe"...see comment below... ; ----------------------------------------------- #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _CleanUpSessUndo() ; ----------------------------------------------- Func _CleanUpSessUndo() Local $_sSrcPath1a = "Select the Session folder to cleanup..." Local $_sSrcPath1b = "Session_Undo" Local $_sFileSelectFolder = FileSelectFolder($_sSrcPath1a, "") ; ----------------------------------------------- If @error Then MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") _CleanUpSessUndo() ; <<<<<<< Here!!!! ; I do NOT want to exit the funcion without previoulsy selecting a folder. This operation MUST BE COMPLETED!! Else ;MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $_sFileSelectFolder) Local $_sSrcPath2 = _FileListToArrayRec($_sFileSelectFolder, $_sSrcPath1b, $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) ; ----------------------------------------------- For $i = 1 To $_sSrcPath2[0] FileDelete($_sSrcPath2[$i] & "\*.u*") Next EndIf EndFunc ;==>_CleanUpSessUndo ; ----------------------------------------------- Edited October 24, 2024 by mr-es335 mr-es335 Sentinel Music Studios
ioa747 Posted October 24, 2024 Posted October 24, 2024 #include <File.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("MustDeclareVars", 1) ; ----------------------------------------------- _CleanUpSessUndo() ; ----------------------------------------------- Func _CleanUpSessUndo() Local $confirmCreate = MsgBox(1, "NOTICE!", "Select the Session folder to cleanup...") If $confirmCreate = 1 Then ;OK Local $sourceFolder Do $sourceFolder = FileSelectFolder("Select Source folder... This operation MUST BE COMPLETED!!", "") Until $sourceFolder <> "" ; ----------------- Local $_sSrcPath2 = _FileListToArrayRec($sourceFolder, "Session_Undo", $FLTAR_FOLDERS, $FLTAR_RECUR, $FLTAR_NOSORT, $FLTAR_FULLPATH) If @error Then MsgBox($MB_ICONERROR, "Error", "No 'Session_Undo' folder found. Exiting.") Return EndIf ; ----------------- For $i = 1 To $_sSrcPath2[0] FileDelete($_sSrcPath2[$i] & "\*.u*") Next EndIf EndFunc ;==>_CleanUpSessUndo ; ----------------------------------------------- mr-es335 1 I know that I know nothing
mr-es335 Posted October 24, 2024 Author Posted October 24, 2024 (edited) ioa747, Succinct...as always!! I once heard, "yes-tidy, I di not no how to spel the wrd, 'programr', and yet today, I 're 1!!" I know nothing!! Edited October 24, 2024 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