aa2zz6 Posted July 26, 2020 Posted July 26, 2020 (edited) When I create my INI file, how would I be able to search for "02=Cat" and change Cat to a specific kind like "02=Maine Coon Cat"? Being able to change whatever would be in section [02=] #include <MsgBoxConstants.au3> #include <Array.au3> ; -------- Create ini file ----------- FileWrite("Search.ini", _ "[Search Animals]" & @CRLF & _ "IGNORE_ERRORS=0" & @CRLF & _ "01=Dog" & @CRLF & _ "02=Cat" & @CRLF & _ "03=Bird" & @CRLF & _ "04=Fish") Sleep(1000) ; ------ End of Create ini file ------ _read() FileDelete("Search.ini") ; Tidy up Func _read() Local Const $hostfile = "Search.ini" $var = IniReadSection($hostfile, "Search Animals") If @error Then MsgBox(4096, "Error", "Unable to read section.") Else For $number = 1 To $var[0][0] ; MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$number][1]) If $var[$number][1] == "Cat" Then MsgBox($MB_SYSTEMMODAL, "Search", "The " & $var[$number][1] & " was found at " & $var[$number][0], 5) ExitLoop ; Exits For - Next loop (stops) when search value, "Cat", is found? EndIf Next EndIf _ArrayDisplay($var, "Search Animals") EndFunc ;==>_read Edited July 26, 2020 by aa2zz6 Added more info to description that might help explain
Nine Posted July 26, 2020 Posted July 26, 2020 IniReadSectionNames will give you all sections of an ini file IniReadSection will give you all keys of an ini section. You just need to loop thru those 2 arrays and find the one you are looking for. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Multi-Threading Made Easy
aa2zz6 Posted July 26, 2020 Author Posted July 26, 2020 (edited) Thanks for the reply! Figured it out. An IniWrite is able to change the value directly IniWrite("Search.ini", "Search Animals", "02", "Maine Coon Cat") Edited July 26, 2020 by aa2zz6
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