I have a GUI and I am trying to get user input and compare the input to the first column in a 2d array.
AutoIt
#include <GUIConstants.au3> #include <File.au3> #include <Array.au3> Global $aRead[][] = [[0],[0]] Global $Path = @ScriptDir & "\data.ini" _FileReadToArray($Path,$aRead,0,";");Reads the contents of data.ini to $aRead. HotKeySet("{ENTER}", "ProcessData");Enter a number and hit enter $Form1 = GUICreate("Form1",800,600,100,100);GUI Main window $edit_field = GUICtrlCreateInput("", 30, 25, 150, 15) GUISetState(@SW_SHOW) GUISetBkColor(0x000000);sets background color on GUI window GUISetState(@SW_SHOW) Func ProcessData() $Input = GUICtrlRead($edit_field) If $Input <> "" Then For $i = 1 To UBound($aRead - 1) If $Input == $aRead[$a] Then $Data = $aRead[$a] _ArrayDisplay($Data) ExitLoop EndIf Next GUICtrlSetData($edit_field,"");Clear the input box EndIf EndFunc
data.ini looks like:
1;1 2;2 3;3 4;4
I am trying to use a for loop to compare the user input value to each item in the forst column of my 2d array.
- If a match is found in $aRead[5] then I want to assign a variable to the data in $aRead[5][2] and exit the for loop and make the input box blank and wait for another user input.
- If a match isnt found then blank out the user input box.
The gui crashes when I enter 1 and hit return and I get an error. What am I doing wrong?