Blaq Posted June 29, 2011 Share Posted June 29, 2011 Im looking for a way to use the iniread to find a group of sections maybe with a wildcard, but have no idea if it can even be done. If the ini looked like this: [1|2|3|4|5] test=a|b|c|d [1|3|3|4|5] test1=a|b|c|d [1|3|3|4|5] test2=a|b|c|d [1|4|3|4|5] test3=a|b|c|d I would want to be able to pull all data "[1|2" and get test=a|b|c|d or "[1|3" test1=a|b|c|d and test2=a|b|c|d I have writen a long process that can do this that write a temp ini but was hoping for ideas or a trick to make it simple. Switch StringRight($section, 1) Case "|" $doi = IniReadSectionNames("data\stock.ini") For $x = 1 To $doi[0] $doi2 = StringInStr($doi[$x], $section, 1) If $doi2 > 0 Then $found1 = IniReadSection("data\stock.ini", $doi[$x]) If @error <> 1 Then For $i = 1 To $found1[0][0] IniWrite("data\Work.ini", "Found", $found1[$i][0], $found1[$i][1]) Next EndIf EndIf Next $found = IniReadSection("data\Work.ini", "Found") For $x = 1 To $found[0][0] IniDelete("data\Work.ini", "Found", $found[$x][0]) Next Case Else $found = IniReadSection("data\stock.ini", $section) EndSwitch Hope that is enough code to get the point across. Thanks for any help. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 29, 2011 Moderators Share Posted June 29, 2011 Blaq, Welcome to the AutoIt forum. Here is my take on how you might do it: $sFile = "stock.ini" $sSearch = "1|3" ; Or "1|2" if you wish ; Get section names $aSections = IniReadSectionNames($sFile) ; Clear the result variable $sResult = "" ; Loop through the sections For $i = 1 To $aSections[0] ; if we find the search variable in the section name If StringInStr($aSections[$i], $sSearch) Then ; We get the key/value pairing $aKey = IniReadSection($sFile, $aSections[$i]) ; And add them to the result $sResult &= $aKey[1][0] & "=" & $aKey[1][1] & @CRLF EndIf Next ; And here we see what we got! MsgBox(0, "Result for " & $sSearch, $sResult) Any questions? M23 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 Link to comment Share on other sites More sharing options...
Blaq Posted June 29, 2011 Author Share Posted June 29, 2011 I tried something like that but didnt get it to work because the sections are really words not numbers and it has Organic and Inorganic and as you can see "inORGANIC" some words are in the others but it just hit me to turn on casesense. Now it is working great. Thanks for the help!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 29, 2011 Moderators Share Posted June 29, 2011 Blaq,My pleasure. the sections are really words not numbers and it has Organic and InorganicTop Tip: Give as much info as you can in the initial post (especially details like that!) and you will get replies that better fit your requirements - perhaps fortunately, we cannot read your mind. M23 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 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