Post by Brandon Parker on Jun 13, 2021 19:27:01 GMT -5
Subroutines do not return values, but Functions are meant to be able to return a value. For Functions, simply set the name of the function equal to what you want to return. The name of the function should have "$" at the end and prior to the opening parenthesis of the parameter list if you want to return a string variable.
Now, that being said, you can pass variables into Subroutines and Functions as "ByRef" and any changes you make inside the Subroutine/Function are made to the variable in the scope where the Subroutine/Function was called from. Note that you should not have local variables that are the same as Global variables.
Arrays and Structs are always Global...
Global variables have global scope and can be seen throughout the program.
Local variables have scope at the level which they are being used unless you pass them into a Subroutine/Function with "ByRef" as mentioned above. When you traverse up the call stack above where a local variable is first used, it will no longer be available.