RosarioC Posted April 7, 2010 Share Posted April 7, 2010 Hello, My name's Rosario, i've been trying to use a function that takes an index of an array, then adds that value to the variable assigned to that index. example: Global $ArrayIndex = 12 Global $GUI[$ArrayIndex]; $GUI[0] = $appointmentsCTRL $GUI[1] =$DoctorName $GUI[2] = $address $GUI[3] = $Month_Date $GUI[4] = $Calander $GUI[5] = $DOA2 $GUI[6] = $Month $GUI[7] = $Date $GUI[8] = $Year $GUI[9] = $Create $GUI[10] = $DOA $GUI[11] = $Data func addDatatoCTRL($ArrayIndex ,$Data) local $i; for $i = 0 to $ArrayIndex GUICtrlSetData($GUI[$i],$data) next return $i; endfunc the return Data fubction: func ReadFromCTRL($ArrayIndex) local $i local $Data for $i = 0 to $ArrayIndex GUICtrlRead($GUI[$i],$Data) next return $Data endfunc and tried this: func addDatatoCTRL($ArrayIndex ,$Data) switch $ArrayIndex case 1 GUICtrlSetData($GUI[1],$Data); case 2 GUICtrlSetData($GUI[2],$Data); case 6 GUICtrlSetData($GUI[6],$Data); endswitch return $ArrayIndex endfunc the return function was similar to the one above, any help would appreciated. Thank you Link to comment Share on other sites More sharing options...
Spiff59 Posted April 7, 2010 Share Posted April 7, 2010 It's hard to tell exactly what you are trying to do... The commands GUICtrlReadData() and GUICtrlSetData() are used to read from and write to controls created within a GUI. The controls are referenced via the handle returned when the control is created. In your example, you've created only program variables, and have not defined any actual controls. Try playing with the following and see if things become clearer... Global $label[11] ; an array of variables that will hold the handles that point to label controls $DoctorName = "Jeykl" $Month_Date = "20 December" ; Create GUI $MyGUI = GUICreate("",400,400) ; a GUI For $i = 1 to 10 GUICtrlCreateLabel("Label " & $i & ":", 10, 25 * $i, 80, 20) ; I did not assign the returned handle, so this control cannot be referenced. It's value is static $label[$i] = GUICtrlCreateLabel("", 90, 25 * $i, 200, 20) ; The handles for these controls have been stored to the $label array to allow them to be accessed/manipulated Next GUISetState() ;------------------------------------------------------------------------------- Sleep(2500) addDatatoCTRL(5 ,$DoctorName) ; update the 5th label Sleep(2500) addDatatoCTRL(8 ,$Month_Date) ; update the 8th label Sleep(2500) Exit ;------------------------------------------------------------------------------- Func addDatatoCTRL($index ,$data) GUICtrlSetData($label[$index],$data) Beep(800, 50) EndFunc Link to comment Share on other sites More sharing options...
Yoriz Posted April 8, 2010 Share Posted April 8, 2010 Also not quite sure what Your after , is the following anything near ? Global Enum $appointmentsCTRL, $DoctorName, $address, $Month_Date, $Calander, $DOA2, $Month, $Date, $Year, $Create, $DOA, $Data Global $hGuiCtrlLabel[12], $sGuiSetData[12], $sGuiCtrlRead[12] $sGuiSetData[$appointmentsCTRL] = "Some Appointment" $sGuiSetData[$DoctorName] = "Some Doctor" $sGuiSetData[$address] = "Some address" GUICreate("Test") $hGuiCtrlLabel[$appointmentsCTRL] = GUICtrlCreateLabel($sGuiSetData[$appointmentsCTRL],10,10) $hGuiCtrlLabel[$DoctorName] = GUICtrlCreateLabel($sGuiSetData[$DoctorName],10,40) $hGuiCtrlLabel[$address] = GUICtrlCreateLabel($sGuiSetData[$address],10,70) GUISetState() $sGuiCtrlRead[$appointmentsCTRL] = GUICtrlRead($hGuiCtrlLabel[$appointmentsCTRL]) MsgBox(0,"Pause","$appointmentsCTRL = " & $sGuiCtrlRead[$appointmentsCTRL]) GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
RosarioC Posted April 8, 2010 Author Share Posted April 8, 2010 He, right, forgot to post the code that creates the GUI, :-p expandcollapse popup#include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Timers.au3> MsgBox(0,"Welcome to Appointment v1.0","have fun"); #Region ### START Koda GUI section ### Form=C:\Users\RO\Documents\AutoITscripts\Appointments\appointments.kxf $appointment = GUICreate("Appoitnment reminder v1.0", 1024, 798, 190, 120) $appointmentsCTRL = GUICtrlCreateGroup("Appointments Edit", 16, 40, 553, 241) $DoctorName = GUICtrlCreateInput("", 104, 72, 169, 21) GUICtrlSetCursor (-1, 5) $address = GUICtrlCreateInput("", 104, 106, 169, 21) GUICtrlSetCursor (-1, 5) $DoctorNam = GUICtrlCreateLabel(" Doctor's name", 24, 72, 75, 17) $addres = GUICtrlCreateLabel(" Address", 42, 104, 45, 17) GUICtrlSetCursor (-1, 5) $Month_Date = GUICtrlCreateMonthCal("2010/04/06", 328, 72, 229, 164) GUICtrlSetState($Month_Date, $GUI_HIDE) $DateOFAppointment = GUICtrlCreateLabel(" D.O.A", 48, 136, 42, 17) $Calander = GUICtrlCreateButton("", 280, 136, 32, 32, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Users\RO\Documents\AutoITscripts\Appointments\Images\Button images\Calendar.bmp", -1) $DOA2 = GUICtrlCreateGroup("Date of Appoint", 96, 160, 169, 57) $Month = GUICtrlCreateInput("", 104, 184, 33, 21) GUICtrlSetTip($Month, "Month") $slash = GUICtrlCreateLabel("/", 144, 184, 9, 17) $Date = GUICtrlCreateInput("", 160, 184, 33, 21) GUICtrlSetTip($Date, "Date") $Slash2 = GUICtrlCreateLabel("/", 200, 184, 9, 17) $Year = GUICtrlCreateInput("1970", 216, 184, 33, 21) GUICtrlSetLimit($Year, 4) GUICtrlSetTip($Year, "Year") GUICtrlCreateGroup("", -99, -99, 1, 1) $Create = GUICtrlCreateButton("Create Appointment", 96, 232, 105, 25) $DOA = GUICtrlCreateInput("", 104, 136, 169, 21) GUICtrlSetState($DOA, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) $Data = GUICtrlCreateList("", 600, 56, 200, 214) GUICtrlSetData(-1, "Dr. Herbert, 310 spooner street, 12/02/1984") GUICtrlSetCursor (-1, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### there we are :-D 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