autohit Posted October 19, 2015 Posted October 19, 2015 (edited) Hi guys,I am a fairly new poster and is probably over thinking this. I have 4 arrays, 3 input box and and 1 combo box. The first array is read into the list of the combo box. When the first item in combo box 1 is selected, each of the 3 text box is populated accordingly with the value from index 1 of the different arrays. When the second item in the combo box is selected, it will populate the text boxes with index 2 of the arrays. My question is, how can I do this without hardcoding in the array index number? I have thought about setting a variable to "indexof" array but I was not able to find such thing on autoit.Case $combo_box if GUICtrlRead($combo_box) = $array1[0] Then GUICtrlSetData($inputbox1,$array2[0]) GUICtrlSetData($inputbox2,$array3[0]) GUICtrlSetData($inputbox3,$array4[0]) ElseIf GUICtrlRead($combo_box) = $array1[1] Then GUICtrlSetData($inputbox1,$array2[1]) GUICtrlSetData($inputbox2,$array3[1]) GUICtrlSetData($inputbox3,$array4[1]) Else GUICtrlSetData($inputbox1,$array2[2]) GUICtrlSetData($inputbox2,$array3[2]) GUICtrlSetData($inputbox3,$array4[2]) EndIf Edited October 19, 2015 by autohit
Moderators Melba23 Posted October 19, 2015 Moderators Posted October 19, 2015 autohit,Welcome to the AutoIt forums.I would just search the first array for a match like this:#include <GUIConstantsEx.au3> #include <Array.au3> Global $array1[] = ["A1", "B1", "C1"] Global $array2[] = ["A2", "B2", "C2"] Global $array3[] = ["A3", "B3", "C3"] Global $array4[] = ["A4", "B4", "C4"] $hGUI = GUICreate("Test", 500, 500) $combo_box = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($combo_box, _ArrayToString($array1)) $inputbox1 = GUICtrlCreateInput("", 10, 200, 200, 20) $inputbox2 = GUICtrlCreateInput("", 10, 250, 200, 20) $inputbox3 = GUICtrlCreateInput("", 10, 300, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $combo_box $iIndex = _ArraySearch($array1, GUICtrlRead($combo_box)) GUICtrlSetData($inputbox1, $array2[$iIndex]) GUICtrlSetData($inputbox2, $array3[$iIndex]) GUICtrlSetData($inputbox3, $array4[$iIndex]) EndSwitch WEndPlease ask if you have any questions.M23 autohit 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
autohit Posted October 19, 2015 Author Posted October 19, 2015 thank you so much Melba23. This works but let me see if I understand this correctly.Whenever the $combo_box is clicked (triggered in an event), _ArraySearch searches for the string selected and return it's state (int). In this case, the state is an index which is use to populate the other text boxes? Let me know if I'm understanding this wrong.
Moderators Melba23 Posted October 20, 2015 Moderators Posted October 20, 2015 autohit,_ArraySearch searches in the array you use to populate the combo and returns the index of the string found - that index is then used to populate the inputs from their arrays because you have the indexes linked.M23 autohit 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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