Jump to content
Sign in to follow this  
Drew

Add items from a INI to a listview.

Recommended Posts

Drew

Alright my GUI has a list view , and the items it needs to display I planned to be done through an INI file.

Being as I will not always know the number of entries in it... How can I make it list all entries?

Here's an example of an entry in the INI.

[Character Name]

Name=Name

Lvl=100

ID=123456789

And on the listview , I was hoping to display it something like this... "Name ( 100 ) - 123456789" , in alphabetical order if thats possible.

I'm not even sure where to start , but arrays come to mind. If anyone could point me in the right direction I would greatly appreciate it.

Thanks,

*Drew

Share this post


Link to post
Share on other sites
DjDeep00

@Drew..Look in the helpfile for INI functions.

Share this post


Link to post
Share on other sites
Drew

I already know how to use INI functions... Thank you.

I need to know how to make it read and list multiple entries in the file, and I won't know how many entries there might be. So how do I tell it to list ALL entries when I don't know what those entries are , or how many?

Share this post


Link to post
Share on other sites
Drew

Alright how would I make it so that it will monitor changes in the files , and update accordingly?

Putting them in a while will make it duplicate the same ones over and over =/.

Share this post


Link to post
Share on other sites
enaiman

I'm still confused about what you really want ....

Do you want to BUILD an ini file or you already have it built and you're only concerned with the listView (displaying all the entries)?


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Drew

I have ones built for testing purposes , but there will be a feature to add to the Ini files through the program.

But currently I just need to be able to display all entries.

Share this post


Link to post
Share on other sites
Drew

Heres a copy of one of the functions that are reading the INI's and putting them on the tabs. ( It doesn't work right now =/ )

Func _Startup_Ene()
    $IniFile = @ScriptDir&"\Ene.ini"
    $EneVar=IniReadSectionNames($IniFile)
    If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $Enevar[0]
    $Section = inireadsection($IniFile, $EneVar[$i])
    $Name = IniRead($IniFile, $Section, "Name", "Default")
    $Lvl = IniRead($IniFile, $Section, "Lvl", "Default")
    $ID = IniRead($IniFile, $Section, "ID", "Default")
    _GUICtrlListBox_AddString($EnemiesList, $Name & " ( " & $Lvl & " ) " & "ID: " & $ID)
    Next
EndIf

Share this post


Link to post
Share on other sites
enaiman

IniReadSectionNames() is the answer for you.

It returns an array of all section names and the number of sections will be stored in the element 0.

You can easily build a For-Next loop to get all your sections displayed.

If the section structure is the same (same keys on every section) your problem is solved. If not ... you will need to use IniReadSection() for every section, read all the keys and values and display them.

EDIT: of course it doesn't work - you're using wrong section names. Here it is fixed:

Func _Startup_Ene()
    $IniFile = @ScriptDir&"\Ene.ini"
    $EneVar=IniReadSectionNames($IniFile)
    If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $Enevar[0]
    $Name = IniRead($IniFile, $Enevar[$i], "Name", "Default")
    $Lvl = IniRead($IniFile, $Enevar[$i], "Lvl", "Default")
    $ID = IniRead($IniFile, $Enevar[$i], "ID", "Default")
    _GUICtrlListBox_AddString($EnemiesList, $Name & " ( " & $Lvl & " ) " & "ID: " & $ID)
    Next
EndIf
Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Drew

Omg you forgot to put the Endfunc!

Rofl , j/p. Your script works great , and best of all , I understand exactly how it works =).

Thank you very much for your time and help ;).

*Drew

Share this post


Link to post
Share on other sites
enaiman

Yep - YOU forgot to put the EndFunc :D

welcome ;)


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites
Drew

Yep - YOU forgot to put the EndFunc :D

welcome ;)

LOL... Guess I had better shutup lol.

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  

×