spaztasticDes Posted May 7, 2008 Posted May 7, 2008 I don't know if anyone has ever asked this before, but I am trying to make a program that will read an ini file, breaking each section down into a tab, I have completed this mainly by copy ans pasting from the help file, but it's a start and I atleast understand most of what I am seeing. Before we continue this is for a game, but all this program is supposed to do is read an ini, break everyting down, then update the ini with the changes I made using the gui. My problem so far is I can not output what is inside each section into the tabs. Like my Ini file has three sections so far Settings, Bot0, Bot1. I want to output all of the settings section under the settings tab, etc etc with the others. This is what I have so far. #include <GUIConstants.au3> GUICreate("Configuration Utility") ; will create a dialog box that when displayed is centered GUISetFont(9, 300) $aini = "Awesom-O.ini" $tab=GUICtrlCreateTab (10,10, 200,100) $widthCell = 70 GUICtrlCreateLabel ("Information", 40,40,70,20); first cell 70 width $var = IniReadSectionNames($aini) If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $var[0] $tab = GUICtrlCreateTabitem ($var[$i]) $info = IniReadSection($aini,$var[$i]) $tab1 = GUICtrlCreateLabel ($info[$i][0], -1, 0) Next EndIf GUICtrlCreateTabitem ("") ; end tabitem definition GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Anyone willing to help?
PsaltyDS Posted May 7, 2008 Posted May 7, 2008 I don't know if anyone has ever asked this before, but I am trying to make a program that will read an ini file, breaking each section down into a tab, I have completed this mainly by copy ans pasting from the help file, but it's a start and I atleast understand most of what I am seeing. Before we continue this is for a game, but all this program is supposed to do is read an ini, break everyting down, then update the ini with the changes I made using the gui. My problem so far is I can not output what is inside each section into the tabs. Like my Ini file has three sections so far Settings, Bot0, Bot1. I want to output all of the settings section under the settings tab, etc etc with the others. You need a separate For/Next loop for the values, inside the For/Next loop for the sections. Demo: #include <GUIConstants.au3> GUICreate("Configuration Utility", 400, 300); will create a dialog box that when displayed is centered $sINI = @ScriptDir & "\Test.ini" GUICtrlCreateLabel("Information", 10, 10, 70, 20); first cell 70 width $ctrlTab = GUICtrlCreateTab(10, 40, 380, 250) $avSec = IniReadSectionNames($sINI) If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else Global $avTabs[$avSec[0] + 1] = [$avSec[0]]; Array to hold tab ctrl IDs ; For each section.. For $iSec = 1 To $avSec[0] $avTabs[$iSec] = GUICtrlCreateTabItem($avSec[$iSec]) $avVals = IniReadSection($sINI, $avSec[$iSec]) ; for each value inside the section For $iVal = 1 To $avVals[0][0] $tab1 = GUICtrlCreateLabel($avVals[$iVal][0] & " = " & $avVals[$iVal][1], 30, 40 + (30 * $iVal), 340, 20) Next Next EndIf GUICtrlCreateTabItem(""); end tabitem definition GUISetState() ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Test.ini file: [English] 1=One 2=Two 3=Three 4=Four [French] 1=Un 2=Deux 3=Trois 4=Quatre [Spanish] 1=Uno 2=Dos 3=Tres 4=Cuatro Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
spaztasticDes Posted May 7, 2008 Author Posted May 7, 2008 Ty very much I have in a way almost completed the script. It opens and shows all the configuration options and everything. Only thing left to do is add a sacve option incase I modify them. This is nice. Ty very much for your help!
nikink Posted May 7, 2008 Posted May 7, 2008 Ty very much I have in a way almost completed the script. It opens and shows all the configuration options and everything. Only thing left to do is add a sacve option incase I modify them. This is nice. Ty very much for your help!Any chance you could share your script afterwards? I'm trying to do the same thing (or similar at least) and would love to know how you've done it.
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