Sign in to follow this  
Followers 0
Bert

IniRead with GUICtrlCreateList

10 posts in this topic

I'm trying to learn about using IniRead, and I'm having trouble getting it to work. I know I'm doing something wrong, but not sure what. I wrote a test script to figure it out, and IniRead keeps erroring out with a return code of 1.

What I'm trying to do is get what is listed in the ini file to show up in the right window.

#include <GUIConstants.au3>
#Include <GuiList.au3>

;--------------------<GUI>---------------------------

GUICreate("Test WIndow", 655, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Global $testlist = GUICtrlCreateList("", 350, 10, 300, 450)
Dim $input

$maintree = GUICtrlCreateTreeView(10, 10, 300, 450)
$oneitem = GUICtrlCreateTreeViewItem("One", $maintree)
$twoitem = GUICtrlCreateTreeViewItem("Two", $maintree)
GUISetState(@SW_SHOW)
;End GUI

Dim $desktop
  While 1
  $msg = GUIGetMsg()
  Select
    Case $msg = $GUI_EVENT_CLOSE
    Exit

;-------<controls>--------------    
    
    Case $msg = $oneitem 
         _GUICtrlListClear($testlist)       
         $var = IniReadSection ("C:\boot.ini", "boot loader")
         MsgBox(4096, "Result", $var)       
         GUICtrlSetData($testlist, $var)
         $data = GUICtrlRead($testlist)

         
    Case $msg = $twoitem 
         _GUICtrlListClear($testlist)
         GUICtrlSetData($testlist, "Two|TWO|twO")
         $data = GUICtrlRead($testlist)
         
;End Controls

         EndSelect
    WEnd
  GUIDelete()
Exit

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you sure you have access to that ini?

Try double clicking the ini and see what happens.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

CODE

#include <GUIConstants.au3>

#Include <GuiList.au3>

;--------------------<GUI>---------------------------

GUICreate("Test WIndow", 655, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Global $testlist = GUICtrlCreateList("", 350, 10, 300, 450)

Dim $input

$maintree = GUICtrlCreateTreeView(10, 10, 300, 450)

$oneitem = GUICtrlCreateTreeViewItem("One", $maintree)

$twoitem = GUICtrlCreateTreeViewItem("Two", $maintree)

GUISetState(@SW_SHOW)

;End GUI

Dim $desktop

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

;-------<controls>--------------

Case $msg = $oneitem

_GUICtrlListClear ($testlist)

$var = IniReadSection(@ScriptDir & "\my.ini", "02-03")

MsgBox(4096, "Result", $var[0][0])

For $i = 1 To $var[0][0]

GUICtrlSetData($testlist, $var[$i][0])

Next

$data = GUICtrlRead($testlist)

Case $msg = $twoitem

_GUICtrlListClear ($testlist)

GUICtrlSetData($testlist, "Two|TWO|twO")

$data = GUICtrlRead($testlist)

;End Controls

EndSelect

WEnd

GUIDelete()

Exit

contents of my.ini

[02-03]

Name=April

Page=02-03

Topic=Dogs

UserStatus=Completed

Due=11/11/05

Section=Student Life

EditStatus=NotChecked

[03-04]

Name=Laura

Page=03-04

Topic=Cars

UserStatus=Completed

Due=11/11/05

Section=Student Life

EditStatus=NotChecked

[04-05]

Name=Jake

Page=04-05

Topic=Math

UserStatus=Incomplete

Due=12/11/05

Section=Academics

EditStatus=NotChecked

[06-07]

Name=April

Page=06-07

Topic=Science

UserStatus=Incomplete

Due=12/11/05

Section=Academics

EditStatus=NotChecked

second question; how does one add a scrollbar to the code section of a post?

codebox instead of code

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

OK, that makes sense. I see what you did.

I think INIread isn't what I need.

How then do I get a list to show up in GUICtrlCreateList using a file as a reference, such as a text file or a ini, with the contents in the file shown in the following format:

item 1

item 2

item 3

Also, I need to be able to click on one item in the list, and have that data read.

I know I can use GUICtrlSetData, but the data then has to be formatted like this: item1|item2|item3

This doesn't work for when one need to add or remove data from the file, it can be extreamly tedious. I have to look at this from a user's point of view of ease of being able to change data.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If you look at your code:

GUICreate("Test WIndow", 655, 500, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_GROUP, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU))

Global $testlist = GUICtrlCreateList("", 350, 10, 300, 450)
Dim $input

$Input is a global variable so you should not use Dim to declare it. It's not really good programming practice to even use Dim as it has weird scope rules, either use local or global. We just went over this on AIM so shame on you. ;)

I'd answer your question but I think you're trying to run before you can walk!

If you search the forum you'll find examples of both reading from an .ini and using StringFormat, I was just posting in a few threads like that the other day.

Edited by ligenza

Share this post


Link to post
Share on other sites

As I said before, and I will say again, I learn by trying to solve a certain problem. silly! :oops: I didn't make the connection on what you were telling me last weeknd! And yes, I fully intend on running before I can walk! :P

Currently the information I'm recompiling is in a excel spreadsheet that is updated about daily. I figured out I may be able to pull the information directly from it to populate the fields. This is something that really needs to get done, so I fully intend I will be a goof and try to run before I can walk! :">

I like to add it is alot easier to look stuff up when you know what you are looking for. Try asking a blind person what the color blue looks like. You will get a real funny answer. I have never heard of StringFormat until you mentioned it. Yes, I could spend hours searching, or I could post the question, and get a quick answer. I did spend a couple of hours trying to find the answer on my own, but I'm like the blind man at this moment! Be patient with me please!

I know you are thinking this about me... ;)

I'm really trying however! :mad2:

Share this post


Link to post
Share on other sites

@vollyman, just ignore the peanut gallery, supposedly that person won't be coming back to the forum to annoy the users anymore, time will tell.

If you don't mind using beta, you might want to look at this thread about excel com udfs

http://www.autoitscript.com/forum/index.php?showtopic=14166


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Actually, ligenza is pretty kewl, though she is just giving me a hard time at the moment! :P She has been great in helping me out with stuff, and she is trying to get me to learn the right way. ;)

I'm currently looking at the link, and have downloaded some of the items there. Alot of the stuff is greek to me, though I'm starting to make sense of it. I'm looking to see how to use the ExcelCOM to see how to pull data so that I can do the following:

1. The spreadsheet has currently 12079 entries. This is updated or changed frequently, so I can't use the line number as a reference point when polling data.

2. Column B has the groups. I need to use this as the reference point of the items in column C. I pulled out the included example from the spreadsheet to show what Im talking about. It will need to be renamed with the *.xls ext to view.

In the example, I need to pull all the items listed in "application" to one GUICtrlCreateList window, and pull all the items listed in "customer service" to another GUICtrlCreateList window. I have about 60 different things that can be listed in column B. Also, for the applications group, I want to break it down alphabetically, so the list that is presented with GUICtrlCreateList won't be so long. (THis is sTarting tO hurt mY brAin)

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