telmob Posted July 11, 2011 Share Posted July 11, 2011 Hello. I have a .ini file with the following contents: [Percent1] 20 25 30 35 40 45 [Percent2] 50 100 How can i put it's contents in a combo box? I can't even read the ini :S I'm still a noob, please be gentle Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 11, 2011 Moderators Share Posted July 11, 2011 telmob,It would be much easier if you had a standard key=value ini file format something like this:[Percent1] 20=20 25=25 30=30 35=35 40=40 45=45 [Percent2] 50=50 100=100Then you could use IniReadSection to get the values into an array and loop through it. Can you alter the ini file or are you stuck with what you have? If so, then we will have to look at rather more cumbersome methods. Let me know and then we can work on it. 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...
telmob Posted July 11, 2011 Author Share Posted July 11, 2011 I'm kinda stuck with that ini, because i need the combo to add new values to the ini, and it seems more difficult to do that with key values. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 11, 2011 Share Posted July 11, 2011 @telmob Look at IniWrite() in the helpfile, it's really easy If you have troubles, post a reproducer (short fully working example script) and someone will take a look. @Melba23 You don't need those extra "values" if you're using IniReadSection #cs [Percent1] 20= 25= 30= [Percent2] ;To close Percent1 or else $asSection line would be IniRead... #ce #include <Array.au3> $asSection = IniReadSection(@ScriptFullPath, "Percent1") _ArrayDisplay($asSection) .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
telmob Posted July 12, 2011 Author Share Posted July 12, 2011 (edited) @AdmiralManHairAlkex Thanks for the help, but this is not working: specifics.ini: [Frequence] 1 2 4 5 10 15 #include <Array.au3> $asSection = IniReadSection(@ScriptDir & "\specifics.ini", "Frequence") _ArrayDisplay($asSection) What's wrong with this? EDIT: Ok, i just saw i need to put those '=' at the end. Let's hope i won't need to use '=' as new data. BUT..... the problem persists... How do i get the ini in the combo? #include <GUIConstants.au3> #include <Array.au3> $asSection = IniReadSection("specifics.ini", "Frequence") $Form1 = GUICreate("Form1", 633, 454, 193, 115) $Combo1 = GUICtrlCreateCombo("", 184, 72, 145, 25) GUICtrlSetData(-1, $asSection) GUISetState(@SW_SHOW) ;~ _ArrayDisplay($asSection) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited July 12, 2011 by telmob Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted July 12, 2011 Share Posted July 12, 2011 Unfortunately GUICtrlSetData doesn't accept an array as "data" (but I see how that would be neat). Here's one way to do it: #include <GUIConstants.au3> #include <Array.au3> $asSection = IniReadSection("specifics.ini", "Frequence") $Form1 = GUICreate("Form1", 633, 454, 193, 115) $Combo1 = GUICtrlCreateCombo("", 184, 72, 145, 25) For $iX = 1 To $asSection[0][0] GUICtrlSetData(-1, $asSection[$iX][0]) Next ;~ GUICtrlSetData(-1, $asSection) GUISetState(@SW_SHOW) ;~ _ArrayDisplay($asSection) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Make sure you read the page on GUICtrlSetData() so you understands why this works and yours did not. Combo, List, ListView, ListViewItem: An Opt("GUIDataSeparatorChar",...) separated list of items. For Combo or List control : If the "data" corresponds to an already existing entry it is set as the default. If the "data" starts with GUIDataSeparatorChar or is an empty string "" the previous list is destroyed. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
telmob Posted July 14, 2011 Author Share Posted July 14, 2011 (edited) Thanks Admiral! Sorry i took so long to reply, but the forum security blocks me most of the time. Maybe because i'm using a shared IP in my 3G modem... :S Edited July 14, 2011 by telmob 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