Jump to content

Add items from a INI to a listview.


Drew
 Share

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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 :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...