Jump to content

Standalone|SciTE Anomaly with script


Go to solution Solved by ioa747,

Recommended Posts

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:

; -----------------------------------------------
#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!!

Error.png

Link to comment
Share on other sites

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'..."

Link to comment
Share on other sites

:)  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 by ioa747
correction

I know that I know nothing

Link to comment
Share on other sites

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 by mr-es335
Link to comment
Share on other sites

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 by mr-es335
Link to comment
Share on other sites

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?..."

 

 

Harry.jpg

Edited by mr-es335
Link to comment
Share on other sites

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 by mr-es335
Link to comment
Share on other sites

#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
; -----------------------------------------------

:)

I know that I know nothing

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...