Sign in to follow this  
Followers 0
theholycow

Populate Listviews/labels with data from ini file

7 posts in this topic

I am working on a function that will take user input and save it in an ini file, that part is easy and already works, but at the same time that the program can be writing to the file, I want a listview or some way to view the information in the file. I have already been playing with IniReadSectionNames and such, but can't quite get it to work. I just need it to read ALL the data in a section (sometimes 5 or 6 keys in a section) and write that to a listview or something similar, and do this for all the sections in the file, and all displayed at once in the Listview. Ideas?


Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites



I am working on a function that will take user input and save it in an ini file, that part is easy and already works, but at the same time that the program can be writing to the file, I want a listview or some way to view the information in the file. I have already been playing with IniReadSectionNames and such, but can't quite get it to work. I just need it to read ALL the data in a section (sometimes 5 or 6 keys in a section) and write that to a listview or something similar, and do this for all the sections in the file, and all displayed at once in the Listview. Ideas?

Does this thread help?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Does this thread help?

No, I already looked in that one. It would but I can't figure out how to recover the data from the ini once it's saved and display it. I think I am doing the exact opposite of that one

Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

No, I already looked in that one. It would but I can't figure out how to recover the data from the ini once it's saved and display it. I think I am doing the exact opposite of that one

Oh, but I made a post which shows how to recover the data.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Oh, but I made a post which shows how to recover the data.

Yeah, I saw, I'm having some trouble with it though. I need it to write the Name of the section in one column, then keyA in the next column, keyB in the next, etc, for every section. Any examples I missed on this? When I replaced the variables in your example with the ones from my code, if the ini had no data, it would create an infinitely long listview with nothing in it, and when there was data in it, it would not be displayed in the listview at all.

Here's a segment of it:

$listview = GuiCtrlCreateListView("Name|key1|key2", 10, 10, 100, 400) 
 $NoItems = Number(IniReadSectionNames($ini))
           If $NoItems = 0 Then
               GUICtrlCreateListViewItem("no content", 1)
               Else 
            For $n = 0 To $NoItems - 1
                GUICtrlCreateListViewItem(IniRead($ini, "listviewitems", $n, ""),$listview);and I formatted the information nicely so you could do this
            Next
            EndIf
I tried adding an If statement to yours to deal with the no content issue, didnt work either, even when the ini was empty. I also replaced your IniRead with IniReadSectionNames because when I tried your way it wanted me to tell it which sections to read, which defeats the purpose...

Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

$NoItems

Is an array, as returned by IniReadSectionNames(), uses....

If $NoItems[0] = 0 Then

... and

For $n = 0 To $NoItems[0]... or For $n = 0 To Ubound($NoItems) - 1

*********************************

Your next use will not work

$NoItems = Number(IniReadSectionNames($ini))... returns a number... IniReadSectionNames() returns a "list of names"

Example

$NoItems = IniReadSectionNames($ini)

for $x = ...

GUICtrlCreateListViewItem(IniRead($ini, $NoItems[$x], $x, ""),$listview)

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

$NoItems

Is an array, as returned by IniReadSectionNames(), uses....

If $NoItems[0] = 0 Then

... and

For $n = 0 To $NoItems[0]... or For $n = 0 To Ubound($NoItems) - 1

*********************************

Your next use will not work

$NoItems = Number(IniReadSectionNames($ini))... returns a number... IniReadSectionNames() returns a "list of names"

Example

$NoItems = IniReadSectionNames($ini)

for $x = ...

GUICtrlCreateListViewItem(IniRead($ini, $NoItems[$x], $x, ""),$listview)

8)

Whew. Ok, using your advice, I figured out how to do it a slightly different way but it works and it works how I originally wanted, only thing left is a small deal, $NoItems changes while the program is open according to user input, and I would prefer to use a function to write to the listview, but the $NoItems variable in the function is determined when the program launches, and so if it changes while the program is open, it wont change in the function, so when it is called to display the data, it shows no new data. how can I refresh $NoItems for the function as well?

Func _ListViewWrite($listview)
    $NoItems = IniReadSectionNames($ini)
    If $NoItems[0] = 0 Then
               GUICtrlCreateListViewItem("no content", $listview)
    ElseIf $NoItems[0] <> 0 Then 
        For $n = 1 To $NoItems[0]
            $writeevent = IniReadSectionNames($ini)
            $eventa = IniRead($ini, $writeevent[$n], "a", "")
            $eventb = IniRead($ini, $writeevent[$n], "b", "")
            $eventc = IniRead($ini, $writeevent[$n], "c", "")
            GuiCtrlCreateListViewItem($writeevent[$n] &"|" &$eventa & "|" &$eventb & "|" &$eventc, $listview)
            
        Next
    EndIf

EDIT: Sorry, forgot to add the code. so you can see how the whole thing is fairly dependent on the number of sections in the ini

Edited by theholycow

Christianity: In the beginning, there was God, who always was there and created everything.Atheism: In the beginning, there was nothing, which exploded. Both sides look bad...

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0