Sign in to follow this  
Followers 0
Sparrowlord

Need Help *Bad*

35 posts in this topic

I need help thinking on how to do this. My dad is a mail man and he needs a program that he can add people into like a database thing.

He would need like a GUI that has a list of everyone, then when he clicks on someone it will bring up there info. Like there address and state and zip code and fowards and stuff like that.

Then beside the list of people theres a button that he can click to add a new person. With the same info as stated before, but there would also need to be an edit button to edit anyone at any time. I have no clue how to start this, so If someone could help me with some ideas, or some code I would love that.

Share this post


Link to post
Share on other sites



If the list is small enough, you can use an INI to hold all the information. If it gets bigger than that, I believe SQL is what you want to look at.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I belive a ini would be good.

Edited by Sparrowlord

Share this post


Link to post
Share on other sites

hows this for a start

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>

GuiCreate("  Postal Express   by Valuater", 612, 412,(@DesktopWidth-612)/2, (@DesktopHeight-412)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Group_1 = GuiCtrlCreateGroup("Search Customers", 10, 10, 250, 390)
$Group_2 = GuiCtrlCreateGroup("Customer Information", 280, 10, 320, 390)
$Combo_3 = GuiCtrlCreateCombo("Route #", 70, 60, 100, 21)
$Button_4 = GuiCtrlCreateButton("Search", 30, 340, 100, 30)
$Button_5 = GuiCtrlCreateButton("View Next", 140, 340, 100, 30)
$Group_7 = GuiCtrlCreateGroup("Route", 20, 30, 230, 140)
$Group_8 = GuiCtrlCreateGroup("Customer", 20, 180, 230, 210)
$Button_9 = GuiCtrlCreateButton("Get Route", 60, 120, 130, 30)
$Combo_10 = GuiCtrlCreateCombo("Search by...", 60, 220, 140, 21)
$Input_11 = GuiCtrlCreateInput("Search Criteria", 40, 270, 190, 20)
$Label_12 = GuiCtrlCreateLabel("Name", 300, 40, 110, 20)
$Input_13 = GuiCtrlCreateInput("", 300, 60, 280, 20)
$Label_14 = GuiCtrlCreateLabel("Address", 300, 90, 90, 20)
$Label_15 = GuiCtrlCreateLabel("Street Name", 380, 90, 140, 20)
$Input_16 = GuiCtrlCreateInput("", 300, 110, 70, 20)
$Input_17 = GuiCtrlCreateInput("", 380, 110, 200, 20)
$Label_18 = GuiCtrlCreateLabel("City", 300, 140, 50, 20)
$Label_19 = GuiCtrlCreateLabel("County/Providence", 430, 140, 120, 20)
$Input_20 = GuiCtrlCreateInput("", 300, 160, 110, 20)
$Input_21 = GuiCtrlCreateInput("", 430, 160, 150, 20)
$Label_22 = GuiCtrlCreateLabel("State", 300, 190, 70, 20)
$Label_23 = GuiCtrlCreateLabel("Zip + 4", 390, 190, 110, 20)
$Input_24 = GuiCtrlCreateInput("", 300, 210, 80, 20)
$Input_25 = GuiCtrlCreateInput("", 390, 210, 190, 20)
$Edit_26 = GuiCtrlCreateEdit("Notes", 300, 240, 280, 90)
$Button_27 = GuiCtrlCreateButton("Update Info", 330, 340, 110, 30)
$Button_28 = GuiCtrlCreateButton("Close", 450, 340, 110, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Wow, Valuater thats insane. Thanks! I dont knnow anything about GUI's

Share this post


Link to post
Share on other sites

All you have to know (for starters) is how you want it to look. GUIBuilder (or Koda) will do the rest.

Share this post


Link to post
Share on other sites

I dont know how to send all the info into a ini or any of that :o

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Oh, well I can do that.

I'm going to borrow some code from Valuater for a minute here.

Suppose you have this input in your GUI (the Name input):

$Input_13 = GuiCtrlCreateInput("", 300, 60, 280, 20)

When you press the Update Info button, created here:

$Button_27 = GuiCtrlCreateButton("Update Info", 330, 340, 110, 30)
a GUI event is sent.

This loop picks up that event and acts accordingly. *edit - the loop itself doesn't pick it up, it's the GuiGetMsg() that picks up the events and sets $msg to the event that was received. The Select block will then look to see if $msg matches any of the defined controls or system events, and do the code inside the Case that matches.

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
  ;;;
    EndSelect
WEnd

The only problem with this code so far is that you don't have any cases for the buttons and such. If you modify the loop to do this, you'll have a msgbox with the info pop up when you press the update button.

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_27
        MsgBox (0, "Updated Info", "Name: " & GUICtrlRead ($Input_13) & @CRLF & "Address: " & GUICtrlRead ($Input_16) & @CRLF & _ 
        "Street Name: " & GUICtrlRead ($Input_17) & @CRLF & "City: " & GUICtrlRead ($Input_20) & @CRLF & _ 
        "County/Providence: " & GUICtrlRead ($Input_21) & @CRLF & "State: " & GUICtrlRead ($Input_24) & _ 
        @CRLF & "Zip + 4: " & GUICtrlRead ($Input_25) & @CRLF & "Notes: " & GUICtrlRead ($Edit_26))
    Case Else
  ;;;
    EndSelect
WEnd

All that requires is simply a bunch of GUICtrlRead functions to get the data. Once you get the data, you can use INIWrite to write them to an INI.

Edit - I think Valuater meant to say Country (the r was missing), but I just left it the way he had it.

Edited by greenmachine

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I am still very lost, I dont understand on how to take the stuff from the ini at:

C:\Postal Express\pe.ini

and put it into the GUI, I am soo lost, I still dont understand how to write to the ini. I am using the code that Valuater posted.

Edited by Sparrowlord

Share this post


Link to post
Share on other sites

INIs are formatted like this.

"FileName.ini" -> the filename. I'm putting it in the folder "C:\path\to\" for example purposes.

When you open it, you see:

[section 1]

Key1=Value1

[section 2]

Key2=Value2

Key3=Value3

So suppose I want to know what Value3 is. I know it's in Key3, under Section 2, in FileName.ini. So I use:

IniRead ("c:\path\to\FileName.ini", "Section 2", "Key3", "")

This code opens the ini, goes to Section 2, and reads Key3. If the key was not found (if I said Key4 instead of Key3), it would return "", because that's my default return.

To take the stuff from the ini and write it to a GUI control, you would use GUICtrlSetData on the control that you're targeting.

To write to an INI, you simply use this format (I am adding a Key4 to Section 1, and setting the value to be Value4):

IniWrite ("C:\path\to\FileName.ini", "Section 1", "Key4", "Value4")

By the way, you could have found all this out just by reading the helpfile. All the info is there.

Share this post


Link to post
Share on other sites

But then, How would I have it so it loads it info into the boxes in the GUI? Like theres going to be multiple customers, how would I have to find the customer and then find all the info for them? I learn best from examples, So if you can show me a LITTTLE peice of code on how I would do this, that would be nice.

Thanks

Share this post


Link to post
Share on other sites

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.5 Prototype

#include <GuiConstants.au3>
#Include <File.au3>

Dim $File_Location = @ScriptDir & "\Routes\"
Dim $num = 0, $Input_[10]
If Not FileExists($File_Location) Then Set_Routes()


GuiCreate("  Postal Express   by Valuater", 612, 412,(@DesktopWidth-612)/2, (@DesktopHeight-412)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Group_1 = GuiCtrlCreateGroup("Search Customers", 10, 10, 250, 390)
$Group_2 = GuiCtrlCreateGroup("Customer Information", 280, 10, 320, 390)
$Combo_3 = GuiCtrlCreateCombo("Route #", 70, 60, 100, 21)
$Button_4 = GuiCtrlCreateButton("Search", 30, 340, 100, 30)
$Button_5 = GuiCtrlCreateButton("View Next", 140, 340, 100, 30)
$Group_7 = GuiCtrlCreateGroup("Route", 20, 30, 230, 140)
$Group_8 = GuiCtrlCreateGroup("Customer", 20, 180, 230, 210)
$Button_9 = GuiCtrlCreateButton("Get Route", 60, 120, 130, 30)
$Combo_10 = GuiCtrlCreateCombo("Search by...", 60, 220, 140, 21)
$Input_11 = GuiCtrlCreateInput("Search Criteria", 40, 270, 190, 20)
$Label_12 = GuiCtrlCreateLabel("Name", 300, 40, 110, 20)
$Input_[1] = GuiCtrlCreateInput("", 300, 60, 280, 20)
$Label_14 = GuiCtrlCreateLabel("Address", 300, 90, 90, 20)
$Label_15 = GuiCtrlCreateLabel("Street Name", 380, 90, 140, 20)
$Input_[2] = GuiCtrlCreateInput("", 300, 110, 70, 20)
$Input_[3] = GuiCtrlCreateInput("", 380, 110, 200, 20)
$Label_18 = GuiCtrlCreateLabel("City", 300, 140, 50, 20)
$Label_19 = GuiCtrlCreateLabel("County/Providence", 430, 140, 120, 20)
$Input_[4] = GuiCtrlCreateInput("", 300, 160, 110, 20)
$Input_[5] = GuiCtrlCreateInput("", 430, 160, 150, 20)
$Label_22 = GuiCtrlCreateLabel("State", 300, 190, 70, 20)
$Label_23 = GuiCtrlCreateLabel("Zip + 4", 390, 190, 110, 20)
$Input_[6] = GuiCtrlCreateInput("", 300, 210, 80, 20)
$Input_[7] = GuiCtrlCreateInput("", 390, 210, 190, 20)
$Edit_26 = GuiCtrlCreateEdit("Notes", 300, 240, 280, 90)
$Button_27 = GuiCtrlCreateButton("Update Info", 330, 340, 110, 30)
$Button_28 = GuiCtrlCreateButton("Close", 450, 340, 110, 30)

GuiSetState()

Get_Routes()


While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_9
        Set_Search()    
    Case $msg = $Button_4
        Set_Customers()
    ;;;
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

; --------------------------- Functions -----------------

Func Set_Routes()
    DirCreate($File_Location)
    FileWriteLine($File_Location & "\Route1.ini", "[Route]")
    FileWriteLine($File_Location & "\Route1.ini", "1=David Jones,12345,That way,East Covina,Conway,CA,95505-4321,BIG DOG!!!")
    FileWriteLine($File_Location & "\Route2.ini", "[Route]")
    FileWriteLine($File_Location & "\Route2.ini", "1=Danny Jones,12345,That way,East Covina,Conway,CA,95505-4321,BIG DOG!!!")
    FileWriteLine($File_Location & "\Route3.ini", "[Route]")
    FileWriteLine($File_Location & "\Route3.ini", "1=Debra Jones,12345,That way,East Covina,Conway,CA,95505-4321,Nice Dog")
EndFunc  ;==>Set_ini

Func Get_Routes()
    $FileList=_FileListToArray($File_Location)
If (Not IsArray($FileList)) Or (@Error=1) Then
    MsgBox (0,"","No Files\Folders Found.")
    Return
EndIf

For $x = 1 to $FileList[0]
    GUICtrlSetData( $Combo_3, $FileList[$x], 1 )
Next

EndFunc

Func Set_Search()
    $num = 0
    GUICtrlSetData($Combo_10, "Name|Address|Street|City|County|Zip+4|Notes")
EndFunc

Func Set_Customers()
    $num = $num + 1
    $temp_route = GUICtrlRead($Combo_3)
    $temp_info = GUICtrlRead($Combo_10)
    If $temp_info = "Name" Then $temp_search = 1
    If $temp_info = "Address" Then $temp_search = 2
    If $temp_info = "Street" Then $temp_search = 3
    If $temp_info = "City" Then $temp_search = 4
    If $temp_info = "County" Then $temp_search = 5
    If $temp_info = "Zip+4" Then $temp_search = 6
    If $temp_info = "Notes" Then $temp_search = 7
    $temp_find = GUICtrlRead($Input_11)
    $length = _FileCountLines($File_Location & $temp_route)
    for $x = 1 to  $length -1
        $temp_file = IniRead($File_Location & $temp_route, "Route", $x, "Not Found")
        If $temp_file = "Not Found" Then 
            MsgBox (0,"","No Files\Folders Found.")
            Return
        EndIf
        $temp_split = StringSplit($temp_file, ",")
        If StringInStr($temp_split[$temp_search], $temp_find) Then
            For $t = 1 to $temp_split[0] -1
            GUICtrlSetData($Input_[$t], $temp_split[$t])
            Next
            GUICtrlSetData($Edit_26, $temp_split[8])
            Return
        EndIf
    Next
EndFunc

1

get route1.ini

2

click "get route"

3

Set "search by..." to "Name"

4

type in "David"

5

Click "Search"

BTW

I did mean County... why would a mail delivery person want a Country??? ( in the USA it is politically correct to use Mail-person... not Mail-Man ... lol, but true)

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

...

BTW

I did mean County... why would a mail delivery person want a Country??? ( in the USA it is politically correct to use Mail-person... not Mail-Man ... lol, but true)

8)

Well why would they need County..? When you send a letter all you have is name, address (number and street), city, state, and zip.

Share this post


Link to post
Share on other sites

notice

"County/Providence"

????

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Well why would they need County..? When you send a letter all you have is name, address (number and street), city, state, and zip.

Your supposed to include the state and zip? Damn... No wonder my bill collectors are peeved, I keep telling them the checks in the mail!

Good point on the County/Country thing both you... I have to agree that the parsing should go by zip first, that seperates them well enough if you know what I mean.

Just one question, I have a really hard time believing this is for a mail-man (Yes I said man, because he said it was for his father... but who knows in this day and age :o). I mean... You would think that Dad would have the state of the art equipment back at the office... and what good is having this information on a PC then? I mean, your not talking about making a map, your talking about a 3rd party application with peoples names/addresses/etc... That can't be legal.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

parsing in our mail offices does go by zip... but

i bult it so they could search by anything ( within the stated info )

ie... a first name, partial address etc

legal... dunno

8)

Green... lighten up


NEWHeader1.png

Share this post


Link to post
Share on other sites

Lighten up? I'm not angry or anything, I'm just making a point.

Share this post


Link to post
Share on other sites

Thanks Valuater, its working great so far!

In your PM you told me to post what else is needed/changed

So heres the list:

Theres only 1 route

A button thats a "add" button and you enter all the info in ( adress, etc.. etc... ) and it saves it to the ini

And a button thats like a view list button( Like everyone on the route in this list), and it has a list like:

John Doe 2603 Washington Road 43812 Town Ohio

Jane Jones 2603 Washington Road 43812 Town Ohio

Jim Carrey 1524 Adam Street 43812 East Ohio

Just one question, I have a really hard time believing this is for a mail-man (Yes I said man, because he said it was for his father... but who knows in this day and age :o). I mean... You would think that Dad would have the state of the art equipment back at the office... and what good is having this information on a PC then? I mean, your not talking about making a map, your talking about a 3rd party application with peoples names/addresses/etc... That can't be legal.

It helps the people my dad trains and it also helps his subs.

Share this post


Link to post
Share on other sites

I have tryed for about an hour now to get the "add" button on there somewhere and I cant get it lined up with anything. :o This script is almost done, if anyone can help me finish it, Ill make sure your name is on there.

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