Jump to content

FileSelectFolder Issues


Recommended Posts

Good day,
I hope that the day finds you well!

The following script "works" for the most part...

; -----------------------------------------------
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Global $g_SetName = ""
; -----------------------------------------------
_BrowseForFolder()
; Requires the following function:
; _MoveSourceAudioData()
; -----------------------------------------------
Func _BrowseForFolder()
    While 1
        $g_SetName = FileSelectFolder("Please select a valid Type_#\Set_Name folder...", "F:\Audio\")
        ; -----------------------------------------------
        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"
                ;_MoveSourceAudioData($g_SetName)
                ExitLoop
            Case $_aGetType[3] = "Type_2"
                ;_MoveSourceAudioData($g_SetName)
                ExitLoop
            Case Else
                MsgBox($MB_TOPMOST, "NOTICE!", "You must to select a valid Type_#\Set_Name folder...")
                ContinueLoop
        EndSelect
    WEnd
EndFunc   ;==>_BrowseForFolder
; -----------------------------------------------

However, if I happen to select a folder path that is incorrect - that is, where that path does not meet certain criteria, the scripts fails.
• See attached image

The path must consist of three elements, 1)  F:\Audio\, 2) a $TypeName variable, and 3) a $SetName variable, along with the supporting "\'s".
• Anything more-or-less must be rejected.
• As can be observed in the image, I selected a subfolder of "F:\Audio\$TypeName\$SetName"

Any-and-all of my attempts at resolving the above has not been successful!

Any comments and|or suggestion would be greatly appreciated.

Thank you for your time...appreciated!

PS: I have attached the supporting script

Error.png

_MoveSourceAudioData.au3

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

When something is not working, the usual way to debug it to write everything into the console and double check the output.

Replace the FileMove with consolWrite command then look:

Is the parameter right ?

does the case works ?
do the variables contain the correct path ?

Do the paths exist ?

Some of my script sourcecode

Link to comment
Share on other sites

Attempt #1

; ------------------------------------------------------
#include <MsgBoxConstants.au3>
; ------------------------------------------------------
_CheckPath()
; ------------------------------------------------------
Func _CheckPath()
    ; F:\Audio\Type_1\Test\wav
    Local $WrongName = "F:\Audio\Type_1\Test\wav"

    Local $One = StringMid($WrongName, 1, 9)
    ;MsgBox(0, "", $One)

    Local $Two = StringMid($WrongName, 10, 7)
    ;MsgBox(0, "", $Two)

    Local $Three = StringMid($WrongName, 17, 4)
    ;MsgBox(0, "", $Three)

    Local $Four = StringMid($WrongName, 21, 4)
    ;MsgBox(0, "", $Four)

    Local $CorrectPath = $One & $Two & $Three
    Local $IncorrectPath = $One & $Two & $Three & $Four
    ;MsgBox(0, "", "Correct path is: " & $CorrectPath)
    ;MsgBox(0, "", "Incorrect path is: " & $IncorrectPath)

    Local $Result = StringCompare($CorrectPath, $IncorrectPath)
    If $Result = 0 Then
        MsgBox(0, "", "Great!!")
    Else
        MsgBox(0, "", "Not Great!!")
    Endif
EndFunc   ;==>_CheckPath
; ------------------------------------------------------

 

Link to comment
Share on other sites

in the _BrowseFolder() function you are calling the file dialog

Local $_aGetType = StringSplit($g_SetName, "\")
        ; -----------------------------------------------
        for $x=1 to $_aGetType[0]
                ConsoleWrite ($_aGetType[$x] & @CRLF)
        Next

This would display the selected path into the console window.

I guess you should use IF statements instead of the select ...

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

And as for the last script, i would display it like this:
 

#include <MsgBoxConstants.au3>
; ------------------------------------------------------
_CheckPath()
; ------------------------------------------------------
Func _CheckPath()
    ; F:\Audio\Type_1\Test\wav
    Local $WrongName = "F:\Audio\Type_1\Test\wav"

    Local $One = StringMid($WrongName, 1, 9)
    ;MsgBox(0, "", $One)

    Local $Two = StringMid($WrongName, 10, 7)
    ;MsgBox(0, "", $Two)

    Local $Three = StringMid($WrongName, 17, 4)
    ;MsgBox(0, "", $Three)

    Local $Four = StringMid($WrongName, 21, 4)
    ;MsgBox(0, "", $Four)

    Local $CorrectPath = $One & $Two & $Three
    Local $IncorrectPath = $One & $Two & $Three & $Four
    ;MsgBox(0, "", "Correct path is: " & $CorrectPath)
    ;MsgBox(0, "", "Incorrect path is: " & $IncorrectPath)

    Local $Result = StringCompare($CorrectPath, $IncorrectPath)
    If $Result = 0 Then
        MsgBox(0, "", "Great!!")
    Else
        MsgBox(0, "", "Not Great!!")
        ConsoleWrite ($CorrectPath & @CRLF & $IncorrectPath & @CRLF)
    Endif
EndFunc   ;==>_CheckPath
; ------------------------------------------------------

so you can see it in the console window what is checked vs what you have

Some of my script sourcecode

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   2 members

×
×
  • Create New...