PcExpert Posted April 8, 2006 Share Posted April 8, 2006 (edited) How do I read something from a ini file into the Listview, Line 8 will read the ini and at line 9 I want that it read from the ini file. But I don't know how to get the info from the ini in the listview. So my question is, How can I do that? #include <GUIConstants.au3>GUICreate("Agenda",300,250, 100,200,-1,$WS_EX_ACCEPTFILES)GUISetBkColor (0x00E0FFFF) ; will change background color$listview = GUICtrlCreateListView ("Afspraak |Locatie|Datum|Tijd ",10,10,280,150);,$LVS_SORTDESCENDING)$button = GUICtrlCreateButton ("Nieuwe afspraak", 75,170,100,20)$item1=GUICtrlCreateListViewItem("item2|col22|col23",$listview)$ini1 = IniRead("afspraken.ini", "Afspraak", "1", "")$item2=GUICtrlCreateListViewItem("$ini1|col12|col13",$listview)$item3=GUICtrlCreateListViewItem("item3|col32|col33",$listview)GUICtrlSetState(-1,$GUI_DROPACCEPTED) ; to allow drag and droppingGUISetState()GUICtrlSetData($item2,"ITEM1")GUICtrlSetData($item3,"||COL33")GUICtrlDelete($item1)Do $msg = GUIGetMsg () Select Case $msg = $button $1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "1", $2) IniWrite("afspraken.ini", "Afspraak", "1", $1) IniWrite("afspraken.ini", "Tijd", "1", $3) IniWrite("afspraken.ini", "Datum", "1", $4) Case $msg = $listview MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2) EndSelectUntil $msg = $GUI_EVENT_CLOSE Edited April 8, 2006 by PcExpert Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 8, 2006 Moderators Share Posted April 8, 2006 Try IniReadSection() place them into an array... Then GUICtrlSetData()... do a search for that in the support forum (IniReadSection()), I've given a few examples over the last 2 weeks on it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
PcExpert Posted April 8, 2006 Author Share Posted April 8, 2006 (edited) OK, thanks. But how can I let the program read This $ini2 = IniRead("afspraken.ini", "Locatie", "1", "")$item2=GUICtrlCreateListViewItem("$ini1|$ini2|col13",$listview) At line two you see this: $item2=GUICtrlCreateListViewItem("$ini1|$ini2|col13",$listview)I want that $ini2 reads the first line, but how can I do that? Because if I Run it now it says $ini2, but it must tell me whats in the $ini2 Edited April 8, 2006 by PcExpert Link to comment Share on other sites More sharing options...
cdkid Posted April 8, 2006 Share Posted April 8, 2006 $ini2 = IniRead("afspraken.ini", "Locatie", "1", "") $item2=GUICtrlCreateListViewItem("'" & $ini1 & "|" & $ini2 &"|col13",$listview) I think that should work, haven't worked much with listviews though. ~cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
PcExpert Posted April 8, 2006 Author Share Posted April 8, 2006 (edited) OK, thanks cdkid, it works! But if a user woul'd like to create a new appointment this:$1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?")$2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?")$3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?")$4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?")IniWrite("afspraken.ini", "Locatie", "1", $2)IniWrite("afspraken.ini", "Afspraak", "1", $1)IniWrite("afspraken.ini", "Tijd", "1", $3)IniWrite("afspraken.ini", "Datum", "1", $4)Must be this:$1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?")$2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?")$3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?")$4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?")IniWrite("afspraken.ini", "Locatie", "2", $2)IniWrite("afspraken.ini", "Afspraak", "2", $1)IniWrite("afspraken.ini", "Tijd", "2", $3)IniWrite("afspraken.ini", "Datum", "2", $4)But how can I do that? Edited April 8, 2006 by PcExpert Link to comment Share on other sites More sharing options...
RazerM Posted April 8, 2006 Share Posted April 8, 2006 You are assigning them all to the same key $1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "2", $2) IniWrite("afspraken.ini", "Afspraak", "2", $1) IniWrite("afspraken.ini", "Tijd", "2", $3) IniWrite("afspraken.ini", "Datum", "2", $4) Should be $1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "2", $2) IniWrite("afspraken.ini", "Afspraak", "1", $1) IniWrite("afspraken.ini", "Tijd", 3", $3) IniWrite("afspraken.ini", "Datum", "4", $4) My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
Valuater Posted April 8, 2006 Share Posted April 8, 2006 You are assigning them all to the same key $1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "2", $2) IniWrite("afspraken.ini", "Afspraak", "2", $1) IniWrite("afspraken.ini", "Tijd", "2", $3) IniWrite("afspraken.ini", "Datum", "2", $4) Should be $1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "2", $2) IniWrite("afspraken.ini", "Afspraak", "1", $1) IniWrite("afspraken.ini", "Tijd", 3", $3) IniWrite("afspraken.ini", "Datum", "4", $4) your right,,,,, just one small error noted IniWrite("afspraken.ini", "Tijd", "3", $3) 8) Link to comment Share on other sites More sharing options...
jackyyll Posted April 8, 2006 Share Posted April 8, 2006 your right,,,,,just one small error notedIniWrite("afspraken.ini", "Tijd", "3", $3)8)I hate small errors like those SO much :s Link to comment Share on other sites More sharing options...
PcExpert Posted April 8, 2006 Author Share Posted April 8, 2006 (edited) Sorry, thats not what I mean. I mean if someone woul'd like to make a new appointment it must be automatically 2So this:$1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?")$2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?")$3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?")$4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?")IniWrite("afspraken.ini", "Locatie", "1", $2)IniWrite("afspraken.ini", "Afspraak", "1", $1)IniWrite("afspraken.ini", "Tijd", "1", $3)IniWrite("afspraken.ini", "Datum", "1", $4)Is right, but to let the user make an other new appointment it must be this:$1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?")$2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?")$3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?")$4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?")IniWrite("afspraken.ini", "Locatie", "2", $2)IniWrite("afspraken.ini", "Afspraak", "2", $1)IniWrite("afspraken.ini", "Tijd", "2", $3)IniWrite("afspraken.ini", "Datum", "2", $4)So the appointment that the user already made will not be overwritten. But How can I let the script (if theres already an appointment) edit the iniwrite to this:$1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?")$2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?")$3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?")$4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?")IniWrite("afspraken.ini", "Locatie", "2", $2)IniWrite("afspraken.ini", "Afspraak", "2", $1)IniWrite("afspraken.ini", "Tijd", "2", $3)IniWrite("afspraken.ini", "Datum", "2", $4)So the first appointment will not be overwritten and theres a second line now with the new appointment Edited April 8, 2006 by PcExpert Link to comment Share on other sites More sharing options...
jackyyll Posted April 8, 2006 Share Posted April 8, 2006 (edited) You need to combine IniRead and IniWrite.. Heres an example: IniWrite("afspraken.ini", "Locatie", "2", IniRead("afspraken.ini", "Locatie", "2", "") & ", " & $2) I just used "," for the delimeter, but you can replace the delimiter. That will make the INI look something like this: [Locatie] 2=APPOINTMENT1,APPOINTMENT2,APPOINTMENTx, Edited April 8, 2006 by jackyyll Link to comment Share on other sites More sharing options...
PcExpert Posted April 9, 2006 Author Share Posted April 9, 2006 OK, thanks. But what do I have to change to get it working in this code? CODE: #include <GUIConstants.au3>GUICreate("Agenda",300,250, 100,200,-1,$WS_EX_ACCEPTFILES)GUISetBkColor (0x00E0FFFF) ; will change background color$listview = GUICtrlCreateListView ("Afspraak |Locatie|Datum|Tijd ",10,10,280,150);,$LVS_SORTDESCENDING)$button = GUICtrlCreateButton ("Nieuwe afspraak", 75,170,100,20)$item1=GUICtrlCreateListViewItem("item2|col22|col23",$listview)$ini1 = IniRead("afspraken.ini", "Afspraak", "1", "")$ini2 = IniRead("afspraken.ini", "Locatie", "1", "")$ini3 = IniRead("afspraken.ini", "Datum", "1", "")$ini4 = IniRead("afspraken.ini", "Tijd", "1", "")$item2=GUICtrlCreateListViewItem("'" & $ini1 & "|" & $ini2 &"|" & $ini3 &"|" & $ini4 &"",$listview)$item3 = GUICtrlCreateListViewItem("item3|col32|col33",$listview)GUICtrlSetState(-1,$GUI_DROPACCEPTED) ; to allow drag and droppingGUISetState()GUICtrlSetData($item2, $ini1)GUICtrlSetData($item3,"||COL33")GUICtrlDelete($item1)Do $msg = GUIGetMsg () Select Case $msg = $button $1 = Inputbox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = Inputbox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = Inputbox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = Inputbox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "1", $2) IniWrite("afspraken.ini", "Afspraak", "1", $1) IniWrite("afspraken.ini", "Tijd", "1", $3) IniWrite("afspraken.ini", "Datum", "1", $4) Case $msg = $listview MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2) EndSelectUntil $msg = $GUI_EVENT_CLOSE Thanks for your help Link to comment Share on other sites More sharing options...
Geert Posted April 9, 2006 Share Posted April 9, 2006 expandcollapse popup#include <GUIConstants.au3> #Include <GuiListView.au3>; _GUICtrlListViewDeleteAllItems, _GUICtrlListViewInsertItem GUICreate("Agenda", 300, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF); will change background color $listview = GUICtrlCreateListView("Afspraak |Locatie|Datum|Tijd ", 10, 10, 280, 150);,$LVS_SORTDESCENDING) $button = GUICtrlCreateButton("Nieuwe afspraak", 75, 170, 100, 20) ;~ $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview) ;~ $ini1 = IniRead("afspraken.ini", "Afspraak", "1", "") ;~ $ini2 = IniRead("afspraken.ini", "Locatie", "1", "") ;~ $ini3 = IniRead("afspraken.ini", "Datum", "1", "") ;~ $ini4 = IniRead("afspraken.ini", "Tijd", "1", "") ;~ $item2 = GUICtrlCreateListViewItem("'" & $ini1 & "|" & $ini2 & "|" & $ini3 & "|" & $ini4 & "", $listview) ;~ $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview) ;~ GUICtrlSetState(-1, $GUI_DROPACCEPTED); to allow drag and dropping GUISetState() ;~ GUICtrlSetData($item2, $ini1) ;~ GUICtrlSetData($item3, "||COL33") ;~ GUICtrlDelete($item1) ReadAppointmentsFromIni() Do $msg = GUIGetMsg() Select Case $msg = $button $AfspraakNaam = InputBox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $AfspraakLocatie = InputBox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $AfspraakPlaats = InputBox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $AfspraakDatum = InputBox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") $iAantalAfspraken = Int(Number(IniRead("afspraken.ini", "Metadata", "Aantalafspraken", ""))) $iNieuweAfspraak = $iAantalAfspraken + 1 IniWrite("afspraken.ini", "Metadata", "Aantalafspraken", $iNieuweAfspraak) IniWrite("afspraken.ini", "Afspraken", $iNieuweAfspraak, $AfspraakNaam & "|" & $AfspraakLocatie & "|" & $AfspraakPlaats & "|" & $AfspraakDatum) ReadAppointmentsFromIni() Case $msg = $listview MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2) EndSelect Until $msg = $GUI_EVENT_CLOSE Func ReadAppointmentsFromIni() $iAantalAfspraken = Int(Number(IniRead("afspraken.ini", "Metadata", "Aantalafspraken", ""))) If $iAantalAfspraken > 0 Then _GUICtrlListViewDeleteAllItems($listview) For $i = 1 To $iAantalAfspraken _GUICtrlListViewInsertItem($listview, $i - 1, IniRead("afspraken.ini", "Afspraken", $i, "")) Next EndIf EndFunc ;==>ReadAppointmentsFromIni Link to comment Share on other sites More sharing options...
jackyyll Posted April 9, 2006 Share Posted April 9, 2006 Gah you got to it before me.. Heres what I did: expandcollapse popup#include <GUIConstants.au3> #include <GuiListView.au3> GUICreate("Agenda", 300, 250, 100, 200, -1, $WS_EX_ACCEPTFILES) GUISetBkColor(0x00E0FFFF); will change background color $listview = GUICtrlCreateListView("Afspraak |Locatie|Datum|Tijd ", 10, 10, 280, 150);,$LVS_SORTDESCENDING) $button = GUICtrlCreateButton("Nieuwe afspraak", 75, 170, 100, 20) GUICtrlSetState($listview, $GUI_DROPACCEPTED); to allow drag and dropping GUISetState() PopulateList() Do $msg = GUIGetMsg() Select Case $msg = $button $1 = InputBox("Nieuwe Afspraak", "Wat is de naam van de afspraak?") $2 = InputBox("Nieuwe Afspraak", "Wat is de locatie van de afspraak?") $3 = InputBox("Nieuwe Afspraak", "Hoe laat vindt de afspraak plaats?") $4 = InputBox("Nieuwe Afspraak", "Op welke datum vindt de afspraak plaats?") IniWrite("afspraken.ini", "Locatie", "1", IniRead("afspraken.ini", "Locatie", "1", "") & "," & $2) IniWrite("afspraken.ini", "Afspraak", "1", IniRead("afspraken.ini", "Afspraak", "1", "") & "," & $1) IniWrite("afspraken.ini", "Tijd", "1", IniRead("afspraken.ini", "Tijd", "1", "") & "," & $3) IniWrite("afspraken.ini", "Datum", "1", IniRead("afspraken.ini", "Datum", "1", "") & "," & $4) PopulateList() Case $msg = $listview MsgBox(0, "listview", "clicked=" & GUICtrlGetState($listview), 2) EndSelect Until $msg = $GUI_EVENT_CLOSE Func PopulateList() _GUICtrlListViewDeleteAllItems ($listview) $Afspraak = StringSplit(StringTrimLeft(IniRead("afspraken.ini", "Afspraak", "1", ""), 1), ",") $Locatie = StringSplit(StringTrimLeft(IniRead("afspraken.ini", "Locatie", "1", ""), 1), ",") $Tijd = StringSplit(StringTrimLeft(IniRead("afspraken.ini", "Tijd", "1", ""), 1), ",") $Datum = StringSplit(StringTrimLeft(IniRead("afspraken.ini", "Datum", "1", ""), 1), ",") For $i = 1 To $Afspraak[0] GUICtrlCreateListViewItem($Afspraak[$i] & "|" & $Locatie[$i] & "|" & $Tijd[$i] & "|" & $Datum[$i], $listview) Next EndFunc ;==>PopulateList Link to comment Share on other sites More sharing options...
PcExpert Posted April 10, 2006 Author Share Posted April 10, 2006 Bedankt Geert 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