Code: Select all
GuiFont("NoFac_Text", "one", "two" , "three") ; variadic function call
;https://autohotkey.com/docs/Functions.htm#VariadicCall :
oFontCtrls:= ["NOM_ClientFournisseur_Text", "NoFac_Text", "Date_Text", "Mt_TITLE", "Tx_TITLE", "Ts_TITLE", "Tq_TITLE", "Ty_TITLE", "Qt_TITLE", "Cm_TITLE", "Cb3_Paiement_text", "RefPaiement_text"]
GuiFont("NoFac_Text", oFontCtrls*)
return
;--------------------------------------------------------------------------------
GuiFont(BoldCtrl, RegularCtrls*) {
;--------------------------------------------------------------------------------
For Each, Ctrl in RegularCtrls
msgbox % Ctrl
}
With arrays, you need to add a
* also to the array name in the function
call.
https://autohotkey.com/docs/Functions.htm#VariadicCall wrote:While variadic functions can accept a variable number of parameters, an array of parameters can be passed to any function by applying the same syntax to a function-call:
substrings := ["one", "two", "three"]
MsgBox % Join("`n", substrings*)
But if you always call with an array, you can also do it without a variadic call:
Code: Select all
oFontCtrls:= ["NOM_ClientFournisseur_Text", "NoFac_Text", "Date_Text", "Mt_TITLE", "Tx_TITLE", "Ts_TITLE", "Tq_TITLE", "Ty_TITLE", "Qt_TITLE", "Cm_TITLE", "Cb3_Paiement_text", "RefPaiement_text"]
GuiFont("NoFac_Text", oFontCtrls)
return
;--------------------------------------------------------------------------------
GuiFont(BoldCtrl, RegularCtrls) {
;--------------------------------------------------------------------------------
For Each, Ctrl in RegularCtrls
msgbox % Ctrl
}
Of course, then this variadic call won't work anymore:
Code: Select all
GuiFont("NoFac_Text", "one", "two" , "three")
The code at the top of the post allows both alternatives: an array or a list of parameters, separated by commas.