Parameters and Variables
- PuzzledGreatly
- Posts: 1303
- Joined: 29 Sep 2013, 22:18
Parameters and Variables
Within a function parameters can't be variables but how to create a GUI variable inside a function without declaring the variable as global or static in advance? Is there anyway to pass a variable name into a function? Thanks.
-
- Posts: 52
- Joined: 07 Nov 2015, 22:50
Re: Parameters and Variables
Is this what you want?
Code: Select all
variablename := "x"
%variablename% := 5
test( variablename, x )
test( a, b )
{
msgbox, % a " has the value " b
}
Re: Parameters and Variables
Parameters are variables.PuzzledGreatly wrote:Within a function parameters can't be variables
I assume what you mean is that you cannot use parameters as GUI variables. That is because parameters are non-static local variables. You cannot use non-static local variables as GUI variables.
If the variable already exists as a static or global variable and not as a non-static local variable, you can just pass vvariablename to the Gui command without prior declaration. Otherwise, you must either explicitly declare the variable or make the function assume-global or assume-static.how to create a GUI variable inside a function without declaring the variable as global or static in advance?
Yes, the same ways that you pass any other string into a function...Is there anyway to pass a variable name into a function?
Who is online
Users browsing this forum: garry and 181 guests