myuncleian Posted August 15, 2006 Posted August 15, 2006 First post. For a scripting language, AutoIt is a great development tool If I have a GUI label ($label1) and wish to change the font I can say: GUICtrlSetFont($label1, -1, -1, -1, "Lucida Console") I can put this in a function and call it: ChangeFont($label1) Func ChangeFont(ByRef $nameofctrl) GUICtrlSetFont($nameofctrl, -1, -1, -1, "Lucida Console") EndFunc So, if I have more than one label ($label1, $label2, $label3, ...) I want to say: For $i = 1 to 10 ChangeFont("$label" & $i) Next But it seems I can't pass a control (as a string) into the function. How do I do this without having to say: ChangeFont($label1) ChangeFont($label2) ChangeFont($label3) ...
MHz Posted August 15, 2006 Posted August 15, 2006 You could consider Eval() for passing the string. The variables would need to be seen to use this example. $controlhandle1 = 'handle1' $controlhandle2 = 'handle2' ChangeFont('controlhandle') Func ChangeFont($string_eval) For $i = 1 To 2 MsgBox(0, '', Eval($string_eval & $i)) Next EndFunc
myuncleian Posted August 15, 2006 Author Posted August 15, 2006 Many thanks MHz, I'll try that. I've just found out that I can put controls in arrays so it's probably easier to put all my labels in an array.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now