static initialization, function auto-execution?
Posted: 27 Mar 2024, 10:35
In v1, I was able to use the code below to automatically execute code inside a function without needed to call it from within the auto-execute section.
The code would be executed when the script runs, without first needing to manually call it.
Is this functionality removed from v2? Is there still a way to achieve this without adding MyFunction() to the top of my script?
To further clarify what I'm trying to achieve -- here's an example by Lexikos showcasing this hack: viewtopic.php?p=23235#p23235
The code would be executed when the script runs, without first needing to manually call it.
Is this functionality removed from v2? Is there still a way to achieve this without adding MyFunction() to the top of my script?
Code: Select all
MyFunction() {
Static Init := MyFunction() ; Call function
; Code to be executed
}
To further clarify what I'm trying to achieve -- here's an example by Lexikos showcasing this hack: viewtopic.php?p=23235#p23235
lexikos wrote: ↑06 Aug 2014, 03:20Code: Select all
init_this_file() { static _ := init_this_file() /* This function is called automatically when the script starts, regardless of where it is #included. */ }