mr-es335 Posted November 9, 2023 Posted November 9, 2023 Disclaimer Please note: The following information is being provided for observational purposes only and therefore, the examples provided are for illustrative purposes only! 1. I know that the following code illustration works: ; ----------------------------------------------- Example() ; ------ Func Example() ; A section of code EndFunc ;==>Example ; ----------------------------------------------- 2. However, does the following illustration "work"? ; ----------------------------------------------- Example() ; ------ Func Example() ; A section of code Inside() ; ------ Inside() ; A section of code EndFunc ;==>Inside() EndFunc ;==>Example ; ----------------------------------------------- Thank you for any assistance that one may provide. mr-es335 Sentinel Music Studios
Andreik Posted November 9, 2023 Posted November 9, 2023 (edited) 24 minutes ago, mr-es335 said: However, does the following illustration "work"? No, unless Inside() is a call to a function named Inside that is defined outside the Example() function. As I said you in a previous thread such constructs as nested functions are not valid to AutoIt. Func Example() ; A section of code Inside() ; ------ Inside() ; <<< --- this can be here if it's a function call, but if this starts with Func Inside() it's totally wrong. ; A section of code EndFunc ;==>Inside() <<< --- this cannot be here EndFunc ;==>Example This is valid code: ; ----------------------------------------------- Example() ; ------ Func Example() ; A section of code Inside() ; First call of the function Inside() ; ------ Inside() ; Second call of the function Inside() EndFunc ;==>Example Func Inside() ; Some code EndFunc Edited November 9, 2023 by Andreik
mr-es335 Posted November 9, 2023 Author Posted November 9, 2023 Andreik, Updated example: Example() ; ------ Func Example() ; A section of code Inside() ; Call to the function Inside() EndFunc ;==>Example Func Inside() ; A section of code EndFunc Observations 1. From what I gather, a function should NOT be positioned inside another function • Such would be referred to as "a nested function" 2. A function "call" can be inserted "within" another function 2. A function should be - in a real sense, a stand-alone section of code Both of these fragments would be considered as correct: ; ----------------------------------------------- ; Example #1 Example() Inside() ; ------ Func Example() ; A section of code EndFunc ;==>Example Func Inside() ; A section of code EndFunc ----------------------------------------------- ; Example #2 Example() ; ------ Func Example() ; A section of code Inside() ; Call to the function Inside() EndFunc ;==>Example Func Inside() ; A section of code EndFunc ; ----------------------------------------------- Observations 1. In Example #1, Example() would be executed first, followed by Inside() 2. In Example #2, Example() would be executed first, as before • However, Inside() would only be executed only if Inside() is called within another function, as shown in Example #2. mr-es335 Sentinel Music Studios
Andreik Posted November 9, 2023 Posted November 9, 2023 That's true. But this piece of code cannot run as a single script. ; ----------------------------------------------- ; Example #1 Example() Inside() ; ------ Func Example() ; A section of code EndFunc ;==>Example Func Inside() ; A section of code EndFunc ----------------------------------------------- ; Example #2 Example() ; ------ Func Example() ; A section of code Inside() ; Call to the function Inside() EndFunc ;==>Example Func Inside() ; A section of code EndFunc ; ----------------------------------------------- Example #1 should be a script and example #2 should be another script. This is because two functions cannot have the same in the same script or in the headers included with #include.
mr-es335 Posted November 9, 2023 Author Posted November 9, 2023 (edited) Andriek, I gather that I should have displayed the above in the following manner - for clarity: Both of these fragments would be considered as correct: 1) Example #1: ; ----------------------------------------------- ; Example #1 Example() Inside() ; ------ Func Example() ; A section of code EndFunc ;==>Example Func Inside() ; A section of code EndFunc ----------------------------------------------- 2) Example #2: ----------------------------------------------- ; Example #2 Example() ; ------ Func Example() ; A section of code Inside() ; Call to the function Inside() EndFunc ;==>Example Func Inside() ; A section of code EndFunc ; ----------------------------------------------- PS: I thought that the term "fragment" [...a part broken off, detached, or incomplete] would be understood...but I gather NOT! Edited November 9, 2023 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