Search the Community
Showing results for tags 'ini read data'.
-
Hi i have problem with reading data from INI file. So i need when i put in search field "Test" to get in listbox all results under number 1= with "Test" in name and so my list need to look like this [5018] Test name 2 [5218] Test name 1 [5458] Test nameand when i click on item from list that he appears on $hNameInput Look on image http://prntscr.com/83i7a6 this is my ini file [5018] 0=test1 1=Test name 2 2=0 3=1 [5218] 0=test1 1=Test name 1 2=0 3=1 [5458] 0=test1 1=Test name 2=0 3=1 [5468] 0=test1 1=Name no 1 2=0 3=1 [5345] 0=test1 1=Name no 2 2=0 3=1And here is autoit code #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Users\Mario\Documents\renamer.kxf $hGUI = GUICreate("Form1", 684, 364, 607, 439) GUICtrlCreateGroup(" Search ", 8, 16, 342, 297) GUICtrlCreateLabel("Search for text", 22, 40, 73, 17) $hSearchInput = GUICtrlCreateInput("", 23, 60, 185, 21) $hFinddAllButton = GUICtrlCreateButton("Find All", 222, 58, 75, 25) GUICtrlCreateLabel("Found Items ( click to edit )", 22, 102, 131, 17) $hList = GUICtrlCreateList("", 22, 120, 313, 175) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup(" Edit Item", 355, 16, 321, 137) GUICtrlCreateLabel("Name", 372, 40, 32, 17) $hNameInput = GUICtrlCreateInput("", 371, 60, 289, 21) $hSaveButton = GUICtrlCreateButton("Save", 587, 112, 75, 25) GUICtrlCreateLabel("Item ID", 372, 95, 38, 17) $hItemID = GUICtrlCreateInput("", 369, 112, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY)) GUICtrlCreateGroup("", -99, -99, 1, 1) $hOpenIniButton = GUICtrlCreateButton("Open INI for Edit", 8, 328, 105, 25) $hWriteIniButton = GUICtrlCreateButton("Write Modified INI", 123, 328, 105, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $file While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $hOpenIniButton __openINI() Case $hFinddAllButton Local $iFileExists = FileExists($file) If Not $iFileExists Then MsgBox(48, "Error", "test.ini not found!") EndIf Local $aArray = IniReadSection($file, "5018") If Not @error Then For $i = 1 To $aArray[0][0] GUICtrlSetData($hList, $aArray[$i][1] & @CRLF) Next EndIf EndSwitch WEnd ; open ini Func __openINI() Global $file = FileOpenDialog("Open INI for edit", "", "INI files (*.ini)") If FileExists($file) Then $sFile = FileOpen($file) If @error Then MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended) Else GUICtrlSetState($hOpenIniButton, $GUI_DISABLE) EndIf Else MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended) EndIf EndFunc