Jump to content

Function within a Function


 Share

Go to solution Solved by Dan_555,

Recommended Posts

Good day,

Though I am having "fun" with this, I anunable to get this to work...

I need to put this...

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
; -----------------------------------------------
Call_Intro()
Create_Main_Folder()
Create_Sub_Folders1()
Create_Sub_Folders2()
Call_Outro()
; -----------------------------------------------
Func Call_Intro()
SplashTextOn("NOTICE!!", "Create Session_Master folders...", 450, 50, -1, -1)
Sleep(2000)
EndFunc
; -----------------------------------------------
Func Create_Main_Folder()
    Local $_main_folder="E:\Master_Backup\Session_Master"
    ; ------
    DirCreate($_main_folder)
EndFunc
; -----------------------------------------------
Func Create_Sub_Folders1()
    Local $_main_folder="E:\Master_Backup\Session_Master"
    Local $_perf_folder="E:\Master_Backup\Session_Master\Show"
    Local $_scenes_folder="E:\Master_Backup\Session_Master\Scenes"
    Local $_su_folder="E:\Master_Backup\Session_Master\Session_Undo"
    ; ------
    FileChangeDir ($_main_folder)
    DirCreate($_perf_folder)
    DirCreate($_scenes_folder)
    DirCreate($_su_folder)
EndFunc
; -----------------------------------------------
Func Create_Sub_Folders2()
    Local $_perf_folder="E:\Master_Backup\Session_Master\Show"
    Local $_sd_folder="E:\Master_Backup\Session_Master\Show\Session_Data"
    Local $_su_folder="E:\Master_Backup\Session_Master\Show\Session_Undo"
    ; ------
    FileChangeDir ($_perf_folder)
    DirCreate($_sd_folder)
    DirCreate($_su_folder)
EndFunc
; -----------------------------------------------
Func Call_Outro()
SplashTextOn("NOTICE!!", "Create Session_Master folders completed...", 450, 50, -1, -1)
Sleep(2000)
EndFunc
; -----------------------------------------------

...into this...

#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Local $hGUI=GUICreate("Working Menu", 345, 65)
GUISetFont(12, $FW_BOLD, $GUI_FONTNORMAL, "Calibri")
; -----------------
Local $Create_SM_Folder=GUICtrlCreateButton("Create_SM_Folder", 20, 20, 150, 25)
Local $Exit=GUICtrlCreateButton("Exit", 190, 20, 150, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        $Case $GUI_EVENT_CLOSE, $Exit
            ExitLoop
        $Case Create_SM_Folder  
            Create_SM_Folder()
    EndSwitch
WEnd
; -----------------------------------------------
Func Create_SM_Folder()
    $MyBox=MsgBox($MB_SYSTEMMODAL, "NOTICE?", "Not deployed yet...")
    ; Insert code here]
EndFunc
; -----------------------------------------------

Note: Both DO work on their own...but NOT together. What is it that I am doing wrong?

Sort of at a complete loss on how to do this!! Any assistance would be appreciated!

Someone had provided this...

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
MainFunction()
;
Func MainFunction()
    SubFunction()
    MsgBox(0, "end:", "")
EndFunc  ;==>MainFunction
;
Func SubFunction()
    MsgBox(1024, "Test", "This is a test!")
EndFunc  ;==>SubFunction
; -----------------------------------------------

Thanks!

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

#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

; -----------------------------------------------
Local $hGUI = GUICreate("Working Menu", 345, 65)
GUISetFont(12, $FW_BOLD, $GUI_FONTNORMAL, "Calibri")
; -----------------
Local $Create_SM_Folder = GUICtrlCreateButton("Create_SM_Folder", 20, 20, 150, 25)
Local $Exit = GUICtrlCreateButton("Exit", 190, 20, 150, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Exit
            ExitLoop
        Case Create_SM_Folder
            Create_SM_Folder()
    EndSwitch
WEnd
; -----------------------------------------------


Func Create_SM_Folder()
    Call_Intro()
    Create_Main_Folder()
    Create_Sub_Folders1()
    Create_Sub_Folders2()
    Call_Outro()
EndFunc   ;==>Create_SM_Folder







Func Call_Intro()
    SplashTextOn("NOTICE!!", "Create Session_Master folders...", 450, 50, -1, -1)
    Sleep(2000)
EndFunc   ;==>Call_Intro
; -----------------------------------------------
Func Create_Main_Folder()
    Local $_main_folder = "E:\Master_Backup\Session_Master"
    ; ------
    DirCreate($_main_folder)
EndFunc   ;==>Create_Main_Folder
; -----------------------------------------------
Func Create_Sub_Folders1()
    Local $_main_folder = "E:\Master_Backup\Session_Master"
    Local $_perf_folder = "E:\Master_Backup\Session_Master\Show"
    Local $_scenes_folder = "E:\Master_Backup\Session_Master\Scenes"
    Local $_su_folder = "E:\Master_Backup\Session_Master\Session_Undo"
    ; ------
    FileChangeDir($_main_folder)
    DirCreate($_perf_folder)
    DirCreate($_scenes_folder)
    DirCreate($_su_folder)
EndFunc   ;==>Create_Sub_Folders1
; -----------------------------------------------
Func Create_Sub_Folders2()
    Local $_perf_folder = "E:\Master_Backup\Session_Master\Show"
    Local $_sd_folder = "E:\Master_Backup\Session_Master\Show\Session_Data"
    Local $_su_folder = "E:\Master_Backup\Session_Master\Show\Session_Undo"
    ; ------
    FileChangeDir($_perf_folder)
    DirCreate($_sd_folder)
    DirCreate($_su_folder)
EndFunc   ;==>Create_Sub_Folders2
; -----------------------------------------------
Func Call_Outro()
    SplashTextOn("NOTICE!!", "Create Session_Master folders completed...", 450, 50, -1, -1)
    Sleep(2000)
EndFunc   ;==>Call_Outro
; -----------------------------------------------

 

Edited by Dan_555

Some of my script sourcecode

Link to comment
Share on other sites

Dan_555,

Thanks for this...very much appreciated!

As a side-note, I employ Excel to show comparisons  - as I really want to understand what is the possible solution is to a given scenario.

Combined.thumb.png.89cdb98b48a6a5fc026bfb1f15ea317f.png

As noted, "What I see accomplished here is to place the Function calls within the Main Function! This is so obvious - it is almost scary!!"

Thanks again, Dan-555...appreciated.

PS: I do notice that you, as well as the examples provided in the HelpFile, have [;==>Call_Intro] at the close of each Function. I gather that this addition is provided simply for clarification purposes. Correct?

 

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

Dan_555,

The updates does not appear to be working! I have simplified the script based on your recommendations...

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Local $hGUI = GUICreate("Working Menu", 345, 65)
GUISetFont(12, $FW_BOLD, $GUI_FONTNORMAL, "Calibri")
; -----------------
Local $Create_SM_Folder = GUICtrlCreateButton("Create_SM_Folder", 20, 20, 150, 25)
Local $Exit = GUICtrlCreateButton("Exit", 190, 20, 150, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Exit
            ExitLoop
        Case $Create_SM_Folder
            Create_SM_Folder()
    EndSwitch
WEnd
; -----------------------------------------------
Func Create_SM_Folder()
    Call_Intro()
    Create_Main_Folder()
    Create_Sub_Folders1()
    Create_Sub_Folders2()
    Call_Outro()
EndFunc   ;==>Create_SM_Folder
; -----------------------------------------------
Func Call_Intro()
    MsgBox($MB_SYSTEMMODAL, "", "Inside Call_Intro()")
EndFunc   ;==>Call_Intro
; -----------------------------------------------
Func Create_Main_Folder()
    MsgBox($MB_SYSTEMMODAL, "", "Inside Create_Main_Folder()")
EndFunc   ;==>Create_Main_Folder
; -----------------------------------------------
Func Create_Sub_Folders1()
    MsgBox($MB_SYSTEMMODAL, "", "Inside Create_Sub_Folders1()")
EndFunc   ;==>Create_Sub_Folders1
; -----------------------------------------------
Func Create_Sub_Folders2()
    MsgBox($MB_SYSTEMMODAL, "", "Inside Create_Sub_Folders2()")
EndFunc   ;==>Create_Sub_Folders2
; -----------------------------------------------
Func Call_Outro()
    MsgBox($MB_SYSTEMMODAL, "", "Inside Call_Outro()")
EndFunc   ;==>Call_Outro
; -----------------------------------------------

 

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

Good day,

Just for curiosity, any idea why the script works with the first  [SplashTextOn]...but not the second?

; -----------------------------------------------
#include <AutoItConstants.au3>
#include <FileConstants.au3>
#include <FontConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
; -----------------------------------------------
Local $hGUI=GUICreate("Working Menu", 345, 65)
GUISetFont(12, $FW_BOLD, $GUI_FONTNORMAL, "Calibri")
; -----------------
Local $Create_SM_Folder=GUICtrlCreateButton("Create_SM_Folder", 20, 20, 150, 25)
Local $Exit=GUICtrlCreateButton("Exit", 190, 20, 150, 25)
; -----------------------------------------------
GUISetState(@SW_SHOW, $hGUI)
; -----------------------------------------------
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $Exit
            ExitLoop
        Case $Create_SM_Folder
            Create_SM_Folder()
    EndSwitch
WEnd
; -----------------------------------------------
Func Create_SM_Folder()
    Call_Intro()
    Call_Outro()
EndFunc   ;==>Create_SM_Folder
; -----------------------------------------------
Func Call_Intro()
    ;MsgBox($MB_SYSTEMMODAL, "NOTICE!!", "Create Session_Master folders...", 3)
    SplashTextOn("NOTICE!!", "Create Session_Master folders...", 450, 50, -1, -1)
    Sleep(2000)
EndFunc ;==>Call_Intro
; -----------------------------------------------
Func Call_Outro()
    ;MsgBox($MB_SYSTEMMODAL, "NOTICE!!", "Create Session_Master folders completed...", 1)
    SplashTextOn("NOTICE!!", "Create Session_Master folders completed...", 450, 50, -1, -1)
    Sleep(2000)
EndFunc ;==>Call_Outro
; -----------------------------------------------

It would appear that the last Function "gets hung-up" somehow!
• Both MsgBox's work however.

Link to comment
Share on other sites

Dan_555,

Thanks for this...very much appreciated

Rather that "not being able to assume the obvious"...and an apparent disinclination to "...read the sufferin' HelpFile", I do tend to refer such episodes as "cranial deprivation" [which tends to sound more eloquent that saying "I am stupid!"

Anyhow...thanks again, Dan!

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