Jump to content

Creating a tree based on ini file? How?


CrewXp
 Share

Recommended Posts

I'm trying to create a ladder. It's something we use to keep track of things.

(Reads Ini for key: Section (that's the tree name) then lists it by page#

Example:

-Student Life

:02-03

:03:04

-Academics

:05-06

And when I click on 02-03 for example, it's supposed to show the details of that and let me change it.

Like example, if I click on 02-03:

Assigned To: April

Page #: 02-03

Topic: Dogs

Status: Completed

EditStatus: NotChecked

Due: 11/11/05

Here is an example of my ini file:

[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

The ini file is like that from 05-06,07-08, all the way to 300-301 or something Edited by CrewXp
Link to comment
Share on other sites

This can give you some direction and view how to approach the arrays

this was tested with your ini file and it worked

; please place the location of the ini file here
Dim $Location = "C:\Temp\my.ini"

Dim $Sec_data
#include "GUIConstants.au3"



If Not FileExists( $Location) Then
    MsgBox(0,"Sorry"," the ini file was not found   ")
    Exit
EndIf


Call("Read_Sections")




$PT_win = GuiCreate(" My Ladder,   by QTasc", 240,120)

$button_1 = GUICtrlCreateButton("A&ccept", 20, 80, 60, 23)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$button_2 = GUICtrlCreateButton("C&ancel", 160, 80, 60, 23)

;Create 1 combo box, give focus and populate with contents
$combo_1 = GUICtrlCreateCombo( "", 53, 43, 123, 20)
GUICtrlSetState(-1,$GUI_FOCUS) 
GUICtrlSetData(-1,$Sec_data)
;GUICtrlSetFont( -1, 9, 550)

$label_1 = GUICtrlCreateLabel( "Please Choose a File", 20, 15, 250, 20)
GUICtrlSetFont( -1, 10, 600)

GuiSetState (@SW_SHOW)

While 1 
    $LSmsg = GuiGetMsg()
    Select
        case $LSmsg = $button_2 Or $LSmsg = $GUI_EVENT_CLOSE
            Exit
            
        case $LSmsg = $button_1
            
            $LSID = GuictrlRead($combo_1)
            If $LSID = "" Then
                MsgBox(64, "Error", "No File Chosen")
            EndIf
            If $LSID > "" Then
                Call("Read_ini")
            EndIf
            
    EndSelect
WEnd

;---------------------- functions ---------------------------

Func Read_Sections()
    Local $t = 1
    $Sections = IniReadSectionNames($Location)
    for $t = 1 to $Sections[0]
        If @error then ExitLoop
        
        $Sec_data = $Sec_data & $Sections[$t] & "|"
        
    Next
EndFunc

Func Read_ini()
    
    $var = IniReadSection($Location, $LSID)
    If @error Then 
        MsgBox(4096, "", "Error occured, probably no INI file.")
    Else
        For $i = 1 To $var[0][0]
            MsgBox(4096, "",  $var[$i][0] & @CRLF & $var[$i][1])
        Next
    EndIf

    
EndFunc
Hope that helps

8)

NEWHeader1.png

Link to comment
Share on other sites

omg thanks man your the best! I'm about to goto bed so tomorrow, I'll start working on this again.

By the way: The code you just gave, its PERFECT for another thing im putting in my program where users can view their details of their pages assigned to them and open them with it. This tree ladder thing is mainly going to be used for the admins (me). I'll create a regular ladder for them, so they can just view, not change anything.

But I have a question. I've been playing around and this is what I have so far(For the ladder)

PROBLEM: And I'm having trouble. When I click on a item in the tree, it doesn't show the details like it's supposed to. I also havn't included the submit (The Save Button I have) option because I need it to work first.

I have 2 ini's (one to get the tree structure) and (one to view page details)

sections.ini:

[student Life]02-03=

04-05=

06-07=

[Academics]

08-09=

010-11=

012-13=

[People]

014-15=

016-17=

018-19=

[sports]

20-21=

22-23=

24-25=

pagedetails.ini (just some of it)

[02-03]Name=April

Page=2-3

Topic=Title Page

UserStatus=Completed

Due=11/11/05

Section=Student Life

EditStatus=NotChecked

[04-05]

Name=April

Page=4-5

Topic=Title Page

UserStatus=Completed

Due=11/11/05

Section=Student Life

EditStatus=NotChecked

[06-07]

Name=April

Page=6-7

Topic=Title Page

UserStatus=Completed

Due=11/11/05

Section=Student Life

EditStatus=NotChecked

My Code:

Global $macrolist[10], $macrolistdata[50]

#include <GUIConstants.au3>

#Include <Constants.au3>

#include <array.au3>

;===================================> GUI <=======================================

GUICreate("Macro v1.0", 400, 430)

$filemenu = GUICtrlCreateMenu("File")

$optionsmenu = GUICtrlCreateMenu("Options")

$helpmenu = GUICtrlCreateMenu("?")

$fileitem = GUICtrlCreateMenuItem("Exit", $filemenu)

$item = GUICtrlCreateButton("New", 335, 15, 60)

$btnsave = GUICtrlCreateButton("Save", 335, 145, 60)

$treeview = GUICtrlCreateTreeView(6, 6, 200, 250, BitOR($tvs_hasbuttons, $tvs_haslines, $tvs_linesatroot, $tvs_disabledragdrop, $tvs_showselalways), $ws_ex_clientedge)

$sections = IniReadSectionNames("sections.ini")

If @error Then

MsgBox(4096, "", "Error occured, probably no INI file.")

Else

For $i = 1 To $sections[0]

$keys = IniReadSection("sections.ini", $sections[$i])

$item = GUICtrlCreateTreeViewItem($sections[$i], $treeview)

For $x = 1 To $keys[0][0]

GUICtrlCreateTreeViewItem($keys[$x][0], $item)

Next

Next

EndIf

GUISetState()

;================================> End GUI <======================================

$name = IniRead("pagedetails.ini", $item, "Name", "NotFound")

$page = IniRead("pagedetails.ini", $item, "Page", "NotFound")

$topic = IniRead("pagedetails.ini", $item, "Topic", "NotFound")

$status = IniRead("pagedetails.ini", $item, "Status", "NotFound")

$editstatus = IniRead("pagedetails.ini", $item, "EditStatus", "NotFound")

$duedate = IniRead("pagedetails.ini", $item, "Due", "NotFound")

;createMenu()

While 1

$msg = GUIGetMsg()

;If $msg = $gui_event_close Then ExitLoop

;$msg = GUIGetMsg()

Select

;Case $msg = -3 Or $msg = -1 Or $msg = $cancelbutton

Case $msg = $gui_event_close

ExitLoop

Case $msg = $item

GuiCtrlCreateLabel("Assigned To: ", 10, 280, 100, 20, 0x1000)

GuiCtrlCreateInput($name, 10, 300, 100, 20)

GuiCtrlCreateLabel("Page #: ", 120, 280, 100, 20, 0x1000)

GuiCtrlCreateInput($page, 120, 300, 100, 20)

GuiCtrlCreateLabel("Topic: ", 10, 330, 100, 20, 0x1000)

GuiCtrlCreateInput($topic, 10, 350, 100, 20)

GuiCtrlCreateLabel("Status: ", 120, 330, 100, 20, 0x1000)

GuiCtrlCreateInput($status, 120, 350, 100, 20)

GuiCtrlCreateLabel("EditStatus: ", 10, 380, 100, 20, 0x1000)

GuiCtrlCreateInput($editstatus, 10, 400, 100, 20)

GuiCtrlCreateLabel("DUE: ", 120, 520, 380, 20, 0x1000)

GuiCtrlCreateInput($duedate, 120, 400, 100, 20)

EndSelect

Sleep(10)

WEnd

Edited by CrewXp
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...