Jump to content

populate list or listview with ini file section names


Bubnoff
 Share

Recommended Posts

Would like to use

inireadsectionnames

Works, but at a cost. Now if I edit the .ini I have to edit the list to make the other functions coincide with each other.

Viva Autoit ............................ Bubnoff

[quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]

Link to comment
Share on other sites

So I'm not quite sure is this kinda what your looking for ?

#include <GUIConstants.au3>

GUICreate("My GUI list") ; will create a dialog box that when displayed is centered
$var = IniReadSectionNames(@WindowsDir & "\win.ini")
$mylist=GUICtrlCreateList ("", 176,32,121,97)
for $i = 1 to UBound($var)-1
    GUICtrlSetData($mylist,$var[$i])
Next
$close=GUICtrlCreateButton ("my closing button", 64,160,175,25)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()

Wend
Link to comment
Share on other sites

@Stampy

you do not need to use ubound(var)-1 since $var[0] stores this value.

Just thought I'll point that out for future ref :whistle:

That's a very bad thing to point out, however. It's better to always use UBound(). Not all array's contain their length in element 0. I guarantee you will try to use element 0 to get the length of an array which does not store it's length there if you get in the habit of using element 0.
Link to comment
Share on other sites

That's a very bad thing to point out, however. It's better to always use UBound(). Not all array's contain their length in element 0. I guarantee you will try to use element 0 to get the length of an array which does not store it's length there if you get in the habit of using element 0.

I wouldn't go so far as to call it a "very bad thing to point out" because personally, I find that rather useful, sure the scenario you mention has happened to me several times, but it is easy to fix; I've simply gotten into the habit of checking for the particular function in the helpfile to see if it returns the number of values in the array.

It's probably better to just use UBound(), but for convenience reasons, If certain functions count the array for me, there is really no sense in me doing it again...right?

Edited by Paulie
Link to comment
Share on other sites

It works ......of course.

Thanks Stampy!!!! And thanks to Valik, Paulie and Cue for clarifying Ubound, the use of which I've never fully grasped. This should make the main part of this project topple like dominoes.

Bubnoff

edit : I'm somewhat embarrassed to point this out as it makes me look bad/lazy, however....

There is a great example of this in the help file that I somehow overlooked... I'm in the process of making

a more thorough examination of .chm as a result. Thanks for your patience.

Edited by Bubnoff

[quote] Use educated speculation to create the illusion of pleasure ...Its the closest you'll ever get.- Anon [/quote]

Link to comment
Share on other sites

A good point Valik, will be more carefull and try not make it a habit but i ,like paulie, usually check the helpfile anyway . In this scenario seeing as IniReadSectionNames() has already stored the value in element 0 i thought it will be better to use it than call a function to return the value again.

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...