mlewis412 Posted January 2, 2015 Share Posted January 2, 2015 (edited) Hello every one! I seemed to hit a snag and am in need of your sage advice I am trying to write to a .ini file on information that is generated within the in Listbox. In my efforts, I was able to only get the last line to write to the .ini file. Any help would be greatly appreciate ! expandcollapse popup#include <AVIConstants.au3> #include <GuiConstantsEx.au3> #include <TreeViewConstants.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <WindowsConstants.au3> #include <ScreenCapture.au3> #include <Misc.au3> #include <StaticConstants.au3> #include <Array.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> $parentgui=GUICreate("EPM Tools - By Michael Lewis", 400, 420) GUISetState(@SW_SHOW) GUISwitch($parentgui) $iButton2 = GUICtrlCreateButton("Encounter # Copy", 20, 50, 185, 22) $iButton11 = GUICtrlCreateButton ("Save", 250,310,40,22) $iInput = GUICtrlCreateList ("", 250,2,140,300 ) ;Encounter input While 1 $iMsg = GUIGetMsg() Switch $iMsg GUISetState(@SW_SHOW) Case $iButton2 ;Encounter Copier Button GUICtrlSetData ($iInput, "Information1") GUICtrlSetData ($iInput, "Information2") GUICtrlSetData ($iInput, "Information3") Case $iButton11 ;SAVE $inputread= GUICtrlRead($iInput) IniWrite(@ScriptDir & "/encounters.ini","Encounters","Input1",$inputread) MsgBox (0,"File Saved!","File Saved!") GUISetState(@SW_SHOW) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited January 2, 2015 by mlewis412 Link to comment Share on other sites More sharing options...
BrewManNH Posted January 2, 2015 Share Posted January 2, 2015 The problem is that you didn't read the help file closely enough. When using GUICtrlRead on a listbox it states: Combo, List The value selected If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
kylomas Posted January 2, 2015 Share Posted January 2, 2015 mlewis42, Try it like this... expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> $parentgui = GUICreate("EPM Tools - By Michael Lewis", 400, 420) GUISetState(@SW_SHOW) GUISwitch($parentgui) $iButton2 = GUICtrlCreateButton("Encounter # Copy", 20, 50, 185, 22) $iButton11 = GUICtrlCreateButton("Save", 250, 310, 40, 22) $iInput = GUICtrlCreateList("", 250, 2, 140, 300) ;Encounter input GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg ;GUISetState(@SW_SHOW) ; not needed in this loop - moved to after controls are defined Case $iButton2 ;Encounter Copier Button GUICtrlSetData($iInput, "Information1") GUICtrlSetData($iInput, "Information2") GUICtrlSetData($iInput, "Information3") Case $iButton11 ;SAVE for $1 = 0 to _GUICtrlListBox_GetCount($iInput) - 1 ; 0 based count of items $inputread = _GUICtrlListBox_Gettext($iInput, $1) ; item text IniWrite(@ScriptDir & "/encounters.ini", "Encounters", "Input" & $1+1, $inputread) ; keys must be unique next MsgBox(0, "File Saved!", "File Saved!") ;GUISetState(@SW_SHOW) Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
mlewis412 Posted January 2, 2015 Author Share Posted January 2, 2015 kylo, Thank you so much... works like a charm Link to comment Share on other sites More sharing options...
kylomas Posted January 2, 2015 Share Posted January 2, 2015 (edited) Before you get too much further into using an INI file, note, each key must be unique, otherwise you will be writing over an existing key without realizing that you are. You should give much thought to data structure before trying to use an ini file in this way. edit: This looks like you might be starting down the road of problem ticket tracking. Search for others that have tried this to get more info... Edited January 2, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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