Jump to content

GUI that looks in an ini for a dynamic key, if finds it, it shows the sections the key is found in in drop-down. How can I do this? Thanks!


CrewXp
 Share

Recommended Posts

I'm trying to make a program that reads an ini for the key: Name then displays info about that section. When a user logs in, their name is assigned to the variable $user, which is also equal to the key: Name. How can I do this? This was a bit of code which has the idea im looking for from another dedicated user. Thx

Example: User's name is April, they log in and press the shortcut for this program. It loads and then shows a drop down box of the pages they have (it looks in each section to see if their $user is in a key called Name. If it finds it, it shows it in the drop down). Then they select their page, click open and it opens the page W:\01-02.indd ('page'.indd)

; please place the location of the ini file here

Dim $Location = "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

my.ini example:

[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

Example, if April logs in, and $user is April, it checks sections with the Key: April and displays the sections its found in. So 02-03 and 06-07 will be shown in the drop-down. Then they can select it and click open to open it. 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...