Jump to content

Pass a parameter in a GUICreate Menu


Go to solution Solved by ioa747,

Recommended Posts

Good day,

Firstly, I hope that I have provided an appropriate title for this posting?

Secondly, in the following script, in the function entitled, "_LaunchFolder($_sDstPath1b)" , as noted in the comments,

"#cs Instead of employing ClipPut($_sSrcPath), I want to pass $_sSrcPath2 to _ObtainAudioDataListing(). This would negate the need for [;Obtain path from user input] and the subsequent [$MyPath = InputBox] statement in that following script. How would this be accomplished? #ce"
Β 

; -----------------------------------------------
#include <File.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Local $hGUI = GUICreate("ShowDevMainMenu", 220, 135)
GUISetFont(13, 800, 0, "Calibri")
; -----------------------------------------------
; COLUMN 1 BUTTONS
Local $_sSrcPath1a = GUICtrlCreateButton("Launch Audio Folder", 10, 10, 200, 25)
Local $_sSrcPath1b = GUICtrlCreateButton("Obtain Set Name", 10, 40, 200, 25)
Local $_sSrcPath1c = GUICtrlCreateButton("Obtain Audio Data Listing", 10, 70, 200, 25)
Local $_sSrcPath1d = GUICtrlCreateButton("Exit", 10, 100, 200, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $_sSrcPath1a
            _LaunchAudioFolder()
        Case $_sSrcPath1b
            _ObtainSetName()
        Case $_sSrcPath1c
            _ObtainAudioDataListing()
        Case $_sSrcPath1d
            _ExitMe()
    EndSwitch
WEnd
; -----------------------------------------------
Func _LaunchAudioFolder()
    ; Source Data
    Local $_sSrcPath = "F:\Audio"
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 195, 100, 550, 650)
EndFunc   ;==>_LaunchAudioFolder
; -----------------------------------------------
Func _ObtainSetName()
    ; Source data
    Local $_sSrcPath = InputBox("NOTICE!", "Enter Set Name...", "", "", 200, 130)
    ; -----------------
    ; Destination data
    Local $_sDstPath1b = $_sSrcPath
    ; -----------------------------------------------
    _RenameT1Folder($_sDstPath1b)
EndFunc   ;==>_ObtainSetName
;-----------------------------------------------
Func _RenameT1Folder($_sDstPath1b)
    ; Source data
    Local $_sSrcPath = "F:\Audio\Masters\Type_1"
    ;----------------
    ; Destination data
    Local $_sDstPath1a = "F:\Audio\Type_1"
    ;-----------------------------------------------
    DirCopy($_sSrcPath, $_sDstPath1a & "\" & $_sDstPath1b, $FC_OVERWRITE + $FC_CREATEPATH)
    ;-----------------------------------------------
    _LaunchFolder($_sDstPath1b)
EndFunc   ;==>_RenameT1Folder
;-----------------------------------------------
Func _LaunchFolder($_sDstPath1b)
    ; Source Data
    Local $_sSrcPath = "F:\Audio\Type_1\" & $_sDstPath1b & "\wav"
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 1180, 100, 550, 650)
    ; -----------------------------------------------
    #cs Instead of employing ClipPut($_sSrcPath), I want to pass $_sSrcPath2 to _ObtainAudioDataListing().
    This would negate the need for [;Obtain path from user input] and the subsequent [$MyPath = InputBox] statement in that following script.
    How would this be accomplished?
    #ce
    ClipPut($_sSrcPath)
    ;Local $_sSrcPath2 = $_sSrcPath
EndFunc   ;==>_LaunchFolder
; -----------------------------------------------
Func _ObtainAudioDataListing()
    Local $MyPath = ""
    Local $MyList = ""
    ;----------------
    ; Obtain path from user input
    $MyPath = InputBox("NOTICE!", "Enter the complete .wav file path...", "", "", 200, 130)
    ; -----------------------------------------------
    ; Assign $MyPath to $MyList and create the array
    $MyList = _FileListToArray($MyPath)
    ; Create the data file
    _FileCreate($MyPath & "\FileListing.txt")
    ; Write the array to the data file
    _FileWriteFromArray($MyPath & "\FileListing.txt", $MyList)
    ; -----------------------------------------------
    Local $_sSrcPath = $MyPath & "\FileListing.txt"
    _LaunchText($_sSrcPath)
EndFunc   ;==>_ObtainAudioDataListing
; -----------------------------------------------
Func _LaunchText($_sSrcPath)
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 1180, 100, 550, 650)
EndFunc   ;==>_LaunchText
; -----------------------------------------------
Func _ExitMe()
    Exit
EndFunc   ;==>_ExitMe
; -----------------------------------------------

Any assistance in this matter would be greatly appreciated!

Note: I can perform this operation WITHOUT the GUI, but have been unsuccessful WITH the GUI!

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

ioa747,

Like this...

; -----------------------------------------------
#include <File.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Local $hGUI = GUICreate("ShowDevMainMenu", 220, 135)
GUISetFont(13, 800, 0, "Calibri")
; -----------------------------------------------
; COLUMN 1 BUTTONS
Local $_sSrcPath1a = GUICtrlCreateButton("Launch Audio Folder", 10, 10, 200, 25)
Local $_sSrcPath1b = GUICtrlCreateButton("Obtain Set Name", 10, 40, 200, 25)
Local $_sSrcPath1c = GUICtrlCreateButton("Obtain Audio Data Listing", 10, 70, 200, 25)
Local $_sSrcPath1d = GUICtrlCreateButton("Exit", 10, 100, 200, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $_sSrcPath1a
            _LaunchAudioFolder()
        Case $_sSrcPath1b
            _ObtainSetName()
        Case $_sSrcPath1c
            _ObtainAudioDataListing()
        Case $_sSrcPath1d
            _ExitMe()
    EndSwitch
WEnd
; -----------------------------------------------
Func _LaunchAudioFolder()
    ; Source Data
    Local $_sSrcPath = "F:\Audio"
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 195, 100, 550, 650)
EndFunc   ;==>_LaunchAudioFolder
; -----------------------------------------------
Func _ObtainSetName()
    ; Source data
    Local $_sSrcPath = InputBox("NOTICE!", "Enter Set Name...", "", "", 200, 130)
    ; -----------------
    ; Destination data
    Local $_sDstPath1b = $_sSrcPath
    ; -----------------------------------------------
    _RenameT1Folder($_sDstPath1b)
EndFunc   ;==>_ObtainSetName
;-----------------------------------------------
Func _RenameT1Folder($_sDstPath1b)
    ; Source data
    Local $_sSrcPath = "F:\Audio\Masters\Type_1"
    ;----------------
    ; Destination data
    Local $_sDstPath1a = "F:\Audio\Type_1"
    ;-----------------------------------------------
    DirCopy($_sSrcPath, $_sDstPath1a & "\" & $_sDstPath1b, $FC_OVERWRITE + $FC_CREATEPATH)
    ;-----------------------------------------------
    _LaunchFolder($_sDstPath1b)
EndFunc   ;==>_RenameT1Folder
;-----------------------------------------------
Func _LaunchFolder($_sDstPath1b)
    ; Source Data
    Local $_sSrcPath1 = "F:\Audio\Type_1\" & $_sDstPath1b & "\wav"
    ; -----------------------------------------------
    ShellExecute($_sSrcPath1)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath1, "", 1180, 100, 550, 650)
    ; -----------------------------------------------
    ;ClipPut($_sSrcPath)
    Global $_sSrcPath2 = $_sSrcPath1
EndFunc   ;==>_LaunchFolder
; -----------------------------------------------
Func _ObtainAudioDataListing()
    Local $MyPath = $_sSrcPath2
    Local $MyList = ""
        ; -----------------------------------------------
    ; Assign $MyPath to $MyList and create the array
    $MyList = _FileListToArray($MyPath)
    ; Create the data file
    _FileCreate($MyPath & "\FileListing.txt")
    ; Write the array to the data file
    _FileWriteFromArray($MyPath & "\FileListing.txt", $MyList)
    ; -----------------------------------------------
    Local $_sSrcPath = $MyPath & "\FileListing.txt"
    _LaunchText($_sSrcPath)
EndFunc   ;==>_ObtainAudioDataListing
; -----------------------------------------------
Func _LaunchText($_sSrcPath)
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 1180, 100, 550, 650)
EndFunc   ;==>_LaunchText
; -----------------------------------------------
Func _ExitMe()
    Exit
EndFunc   ;==>_ExitMe
; -----------------------------------------------

Β 

Link to comment
Share on other sites

  • Solution

you can use a global variable
somehow like that

; -----------------------------------------------
#include <File.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
Local $hGUI = GUICreate("ShowDevMainMenu", 220, 135)
GUISetFont(13, 800, 0, "Calibri")
; -----------------------------------------------
; COLUMN 1 BUTTONS
Local $_sSrcPath1a = GUICtrlCreateButton("Launch Audio Folder", 10, 10, 200, 25)
Local $_sSrcPath1b = GUICtrlCreateButton("Obtain Set Name", 10, 40, 200, 25)
Local $_sSrcPath1c = GUICtrlCreateButton("Obtain Audio Data Listing", 10, 70, 200, 25)
Local $_sSrcPath1d = GUICtrlCreateButton("Exit", 10, 100, 200, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------

Global $g_sSrcPath2 ; * <---- you can use a global variable

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $_sSrcPath1a
            _LaunchAudioFolder()
        Case $_sSrcPath1b
            _ObtainSetName()
        Case $_sSrcPath1c
            _ObtainAudioDataListing()
        Case $_sSrcPath1d
            _ExitMe()
    EndSwitch
WEnd
; -----------------------------------------------
Func _LaunchAudioFolder()
    ; Source Data
    Local $_sSrcPath = "F:\Audio"
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 195, 100, 550, 650)
EndFunc   ;==>_LaunchAudioFolder
; -----------------------------------------------
Func _ObtainSetName()
    ; Source data
    Local $_sSrcPath = InputBox("NOTICE!", "Enter Set Name...", "", "", 200, 130)
    ; -----------------
    ; Destination data
    Local $_sDstPath1b = $_sSrcPath
    ; -----------------------------------------------
    _RenameT1Folder($_sDstPath1b)
EndFunc   ;==>_ObtainSetName
;-----------------------------------------------
Func _RenameT1Folder($_sDstPath1b)
    ; Source data
    Local $_sSrcPath = "F:\Audio\Masters\Type_1"
    ;----------------
    ; Destination data
    Local $_sDstPath1a = "F:\Audio\Type_1"
    ;-----------------------------------------------
    DirCopy($_sSrcPath, $_sDstPath1a & "\" & $_sDstPath1b, $FC_OVERWRITE + $FC_CREATEPATH)
    ;-----------------------------------------------
    _LaunchFolder($_sDstPath1b)
EndFunc   ;==>_RenameT1Folder
;-----------------------------------------------
Func _LaunchFolder($_sDstPath1b)
    ; Source Data
    Local $_sSrcPath = "F:\Audio\Type_1\" & $_sDstPath1b & "\wav"
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 1180, 100, 550, 650)
    ; -----------------------------------------------
    #cs Instead of employing ClipPut($_sSrcPath), I want to pass $_sSrcPath2 to _ObtainAudioDataListing().
    This would negate the need for [;Obtain path from user input] and the subsequent [$MyPath = InputBox] statement in that following script.
    How would this be accomplished?
    #ce
;~     ClipPut($_sSrcPath)
    $g_sSrcPath2 = $_sSrcPath
EndFunc   ;==>_LaunchFolder
; -----------------------------------------------
Func _ObtainAudioDataListing()
;~     Local $MyPath = ""
    Local $MyList = ""
    ;----------------
    ; Obtain path from user input
;~     $MyPath = InputBox("NOTICE!", "Enter the complete .wav file path...", "", "", 200, 130)
    ; -----------------------------------------------
    ; Assign $MyPath to $MyList and create the array
    $MyList = _FileListToArray($g_sSrcPath2)
    ; Create the data file
    _FileCreate($g_sSrcPath2 & "\FileListing.txt")
    ; Write the array to the data file
    _FileWriteFromArray($g_sSrcPath2 & "\FileListing.txt", $MyList)
    ; -----------------------------------------------
    Local $_sSrcPath = $g_sSrcPath2 & "\FileListing.txt"
    _LaunchText($_sSrcPath)
EndFunc   ;==>_ObtainAudioDataListing
; -----------------------------------------------
Func _LaunchText($_sSrcPath)
    ; -----------------------------------------------
    ShellExecute($_sSrcPath)
    ; -----------------------------------------------
    Sleep(250)
    ; -----------------------------------------------
    WinMove($_sSrcPath, "", 1180, 100, 550, 650)
EndFunc   ;==>_LaunchText
; -----------------------------------------------
Func _ExitMe()
    Exit
EndFunc   ;==>_ExitMe
; -----------------------------------------------

Β 

Β 

Edited by ioa747

I know that I know nothing

Link to comment
Share on other sites

normally allΒ  πŸ‘‰ these are global, no matter what you call them local
any variable is in the main body outside the functions

; -----------------------------------------------
#include <File.au3>
#include <FileConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Opt("MustDeclareVars", 1)
; -----------------------------------------------
πŸ‘‰ Local $hGUI = GUICreate("ShowDevMainMenu", 220, 135)
GUISetFont(13, 800, 0, "Calibri")
; -----------------------------------------------
; COLUMN 1 BUTTONS
πŸ‘‰ Local $_sSrcPath1a = GUICtrlCreateButton("Launch Audio Folder", 10, 10, 200, 25)
πŸ‘‰ Local $_sSrcPath1b = GUICtrlCreateButton("Obtain Set Name", 10, 40, 200, 25)
πŸ‘‰ Local $_sSrcPath1c = GUICtrlCreateButton("Obtain Audio Data Listing", 10, 70, 200, 25)
πŸ‘‰ Local $_sSrcPath1d = GUICtrlCreateButton("Exit", 10, 100, 200, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------

Global $g_sSrcPath2 ; * <---- you can use a global variable

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $_sSrcPath1a
            _LaunchAudioFolder()
        Case $_sSrcPath1b
            _ObtainSetName()
        Case $_sSrcPath1c
            _ObtainAudioDataListing()
        Case $_sSrcPath1d
            _ExitMe()
    EndSwitch
WEnd

Β 

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