Terenz Posted November 29, 2013 Share Posted November 29, 2013 (edited) Hi all, it's hard for me to explain what i need so i have create an example: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("TestForm", 414, 271, 196, 132) $Label1 = GUICtrlCreateLabel("Label1", 8, 8, 404, 153) GUICtrlSetFont(-1, 100, 400, 0, "Arial") $Label2 = GUICtrlCreateLabel("Label2", 0, 160, 285, 108) GUICtrlSetFont(-1, 70, 400, 0, "Arial") GUISetState(@SW_SHOW) ;~ _Change_Size($Label1, 10) ;~ _Change_Size($Label2, 10) Sleep(1000) _Change_Size(BitOR($Label1, $Label2),10) _Change_Size(BitXOR($Label1, $Label2),10) _Change_Size(BitAND($Label1, $Label2),10) Sleep(1000) Func _Change_Size($MyLabel, $Size) GUICtrlSetFont($MyLabel, $Size, 400, 0, "Arial") EndFunc I know i can call 2 times the function, but there is't a way to perform the same operation using only one function? I have try with Bit operator but not work. Is possible or not? Thanks Edited November 29, 2013 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
BrewManNH Posted November 29, 2013 Share Posted November 29, 2013 Use an array, pass the array to the function, loop through the array to find what labels you're wanting to set. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Terenz Posted November 29, 2013 Author Share Posted November 29, 2013 Using an array does mean i need to rewrite a lot of code. I need to store it in this way: $Label[1] = GUICtrlCreateLabel("Label1", 8, 8, 404, 153) $Label[2] = ;etc Why i can't store directly the variable? Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
BrewManNH Posted November 29, 2013 Share Posted November 29, 2013 I'm afraid I have no idea what you mean by "store directly the variable". If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Terenz Posted November 29, 2013 Author Share Posted November 29, 2013 (edited) #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("TestForm", 414, 271, 196, 132) $Label1 = GUICtrlCreateLabel("Label1", 8, 8, 404, 153) GUICtrlSetFont(-1, 100, 400, 0, "Arial") $Label2 = GUICtrlCreateLabel("Label2", 0, 160, 285, 108) GUICtrlSetFont(-1, 70, 400, 0, "Arial") GUISetState(@SW_SHOW) Sleep(1000) Local $MyArr[3] = [$Label1, $Label2] _Change_Size($MyArr, 10) Sleep(1000) Func _Change_Size($MyLabel, $Size) If IsArray($MyLabel) Then For $i = 0 To UBound($MyLabel) - 1 GUICtrlSetFont($MyLabel[$i], $Size, 400, 0, "Arial") Next Else GUICtrlSetFont($MyLabel, $Size, 400, 0, "Arial") EndIf EndFunc ;==>_Change_Size Seems work, i think there isn't a way to declare the Local $MyArray when i call the function in one line instead of two. Edited November 29, 2013 by Terenz Nothing is so strong as gentleness. Nothing is so gentle as real strength Link to comment Share on other sites More sharing options...
l3ill Posted November 29, 2013 Share Posted November 29, 2013 Hi Terenz I think you may be looking for a loop? you want to call the same function over and over again with slight adjustments? then put it in a loop...once we know we are on the right track we can come up with some examples... Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
martin Posted November 29, 2013 Share Posted November 29, 2013 (edited) Using an array is more versatile, but you could do the following to pass the variables the way you want. #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("TestForm", 414, 271, 196, 132) $Label1 = GUICtrlCreateLabel("Label1", 8, 8, 404, 153) GUICtrlSetFont(-1, 100, 400, 0, "Arial") $Label2 = GUICtrlCreateLabel("Label2", 0, 160, 285, 108) GUICtrlSetFont(-1, 70, 400, 0, "Arial") GUISetState(@SW_SHOW) Sleep(1000) _Change_Size($Label1, 10, $Label2, 20);as many IDs and sizes up to 8 pairs Sleep(1000) Func _Change_Size($lab1, $Size1, $lab2 = 0, $size2 = 0, $lab3 = 0, $Size3 = 0, $lab4 = 0, $size4 = 0, $lab5 = 0, $Size5 = 0, $lab6 = 0, $size6 = 0, $lab7 = 0, $Size7 = 0, $lab8 = 0, $size8 = 0) Local $ii, $iPairs = Floor(@NumParams / 2) For $ii = 1 To $iPairs GUICtrlSetFont(Eval("lab" & $ii), Eval("Size" & $ii), "Arial") Next EndFunc ;==>_Change_Size Edit: Removed Call("_Change_Size".. and just used _ChangeSize. (Don't know why I used call - proably thinking about Eval) Edited November 29, 2013 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
DW1 Posted November 29, 2013 Share Posted November 29, 2013 (edited) Alternatively: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("TestForm", 414, 271, 196, 132) $Label1 = GUICtrlCreateLabel("Label1", 8, 8, 404, 153) GUICtrlSetFont(-1, 100, 400, 0, "Arial") $Label2 = GUICtrlCreateLabel("Label2", 0, 160, 285, 108) GUICtrlSetFont(-1, 70, 400, 0, "Arial") GUISetState(@SW_SHOW) Sleep(1000) _Change_Size("Label1|10|Label2|20");as many IDs and sizes as you would like Sleep(1000) Func _Change_Size($SizeString) Local $aSplit = StringSplit($SizeString, '|') For $ii = 1 To Floor($aSplit[0] / 2) * 2 Step 2 GUICtrlSetFont(Eval($aSplit[$ii]), $aSplit[$ii + 1], "Arial") Next EndFunc ;==>_Change_Size Edited November 29, 2013 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
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