Code: Select all
Test_Required_Parameters := IsFunc("Test") - 1
msgbox, % Test_Required_Parameters
Test() ;how to dynamically pass "Test_Required_Parameters" to the function?
Test(a, b, c, d)
{
msgbox, Test()
}
Code: Select all
Test_Required_Parameters := IsFunc("Test") - 1
msgbox, % Test_Required_Parameters
Test() ;how to dynamically pass "Test_Required_Parameters" to the function?
Test(a, b, c, d)
{
msgbox, Test()
}
Code: Select all
Test_Required_Parameters := IsFunc("Test") - 1
arr := []
Loop % Test_Required_Parameters {
arr.push("")
}
Test(arr*) ;how to dynamically pass "Test_Required_Parameters" to the function?
Test(a, b, c, d)
{
msgbox, Test()
}
Code: Select all
;dynamically pass Required Parameters to the function?
;https://www.autohotkey.com/boards/viewtopic.php?p=255146#p255146
Test_Required_Parameters := IsFunc("Test") - 1
arr := []
Loop % Test_Required_Parameters
arr[a_index] := "x_" a_index
;the "*" bellow from "arr*" is necessary to pass the array as parameters!
;if arr* is used, arr[1] = Parameter1, arr[2] = Parameter2, arr[3] = Parameter3, and so on!
;if arr is used, all the "arr" array = parameter1
Test(arr*) ;_______________ Test (Function) _____________
Test(a, b, c, d)
{
msgbox, % "Test() - " a " - " b " - " c " - " d
}
Code: Select all
;onMessage() does not work if function requires more than 4 parameters
OnMessage(0x201, "Test") ;0x201, left mouse down
Gui, Add, Text,, Left Click anywhere in this window.
Gui, Show, w300 h200
return
GuiClose: ;______ gui close _____
ExitApp
Test(a, b, c, d, e) ;________ Test(Function) ___________
{
ToolTip % a " - " b " - " c " - " d " - " e
}
read the manual:
Failure
Failure occurs when Function:
1. is not an object, the name of a user-defined function, or an empty string;
2. is known to require more than four parameters; or
3. in [v1.0.48.05] or older, has any ByRef or optional parameters.
Sometimes it can:
Code: Select all
OnMessage( 0x201, Func("Test").Bind("Hi") ) ;0x201, left mouse down
Gui, Add, Text,, Left Click anywhere in this window.
Gui, Show, w300 h200
return
GuiClose: ;______ gui close _____
ExitApp
Test(a, b, c, d, e) ;________ Test(Function) ___________
{
ToolTip % a " - " b " - " c " - " d " - " e
}
No we cannot - we have options to supply parameters dynamically so that we can make things fit.teadrinker wrote: ↑28 Dec 2018, 12:24Anyway, so we can use functions with any number of parameters. Cheers![]()
Code: Select all
inifile:="C:\Script_ini.ini"
Gui, Status: add, Text, w500 r2, Hello World!
Gui, Status: show, Autosize x%x% y%y%, vet mini
OnMessage(0x03, "storeGuiLoc")
; OnMessage(0x03, Func("storeGuiLoc").Bind(,,,,scrapper_inifile)) ; this didn't work
Return
storeGuiLoc(wParam, lParam)
{
global
X := lParam & 0xFFFF
Y := lParam >> 16
/* if A_GuiControl
Control := "`n(in control " . A_GuiControl . ")"
*/
;ToolTip You are moving the Gui window #%A_Gui% at client coordinates %X%x%Y%.%Control%
; msgbox, % x "and Y`n" y
IniWrite, % x, % inifile, vet_mini_pos, x
IniWrite, % y, % inifile, vet_mini_pos, y
x:=""
y:=""
}
Code: Select all
OnMessage(0x03, Func("storeGuiLoc").Bind(scrapper_inifile))
storeGuiLoc(scrapper_inifile, wParam, lParam) {
}
Users browsing this forum: Bing [Bot] and 399 guests