BrettF Posted November 9, 2006 Posted November 9, 2006 I'm making an adress book program that saves the contacts into a file and then when you want to search for someone, it finds the file then displays the results and the info included in the file. what im having trouble with is where the results display. Its comes up blank ... expandcollapse popup#include <GUIConstants.au3> Dim $name, $DOB, $ADD, $AGE, $PH Global $Result StartScreen () Func StartScreen () ; The Main Screen $Form1 = GUICreate("What Would You Like to do?", 271, 100, 192, 125) $Button1 = GUICtrlCreateButton("Add Entry", 8, 35, 81, 25) $Button2 = GUICtrlCreateButton("Search", 8, 67, 81, 25) GUICtrlCreateLabel("Add an Entry", 96, 40, 65, 25) GUICtrlCreateLabel("Search for someone", 96, 72, 99, 25) GUICtrlCreateLabel("To start; click on an option bellow.", 8, 8, 251, 25) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 GUISetState (@SW_HIDE) AddEntry () Case $msg = $Button2 SearchNameGUI () EndSelect WEnd Exit EndFunc Func AddEntry () ;Adds an entry to save to a .txt $Form1 = GUICreate("Add Entry", 162, 196, 192, 125) GUICtrlCreateLabel("Name:", 8, 8, 56, 17) $name = GUICtrlCreateInput("Name", 64, 8, 89, 21, -1, $WS_EX_CLIENTEDGE) $DOB = GUICtrlCreateInput("DOB", 64, 32, 89, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("DOB:", 8, 32, 56, 17) GUICtrlCreateLabel("Address:", 8, 104, 56, 17) $PH = GUICtrlCreateInput("Phone", 64, 56, 89, 21, -1, $WS_EX_CLIENTEDGE) $AGE = GUICtrlCreateInput("Age", 64, 80, 89, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Phone:", 8, 56, 56, 17) GUICtrlCreateLabel("Age:", 8, 80, 56, 17) $ADD = GUICtrlCreateInput("Adress(s)", 8, 120, 145, 69, -1, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(64,"","Entry Sucessfully added!") GetInfo () GUISetState (@SW_HIDE) StartScreen () Case Else ;;;;;;; EndSelect WEnd Exit EndFunc Func GetInfo () ;Writes the file that contains all the info on a contact $nme = GUICtrlRead ($name) $do = GUICtrlRead ($DOB) $p = GUICtrlRead ($PH) $ag = GUICtrlRead ($AGE) $ad = GUICtrlRead ($ADD) $open = FileOpen ("Contacts\" & $nme & ".txt", 2) FileWriteLine ($open, $nme) FileWriteLine ($open, $do) FileWriteLine ($open, $P) FileWriteLine ($open, $ag) FileWriteLine ($open, $ad) FileClose ($open) EndFunc Func SearchNameGUI () ;the search GUI #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("Search", 200, 40, 192, 125) $Input1 = GUICtrlCreateInput("Name", 8, 8, 113, 21, -1, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("Search!", 128, 8, 65, 25) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 GUISetState (@SW_HIDE) $Input = GUICtrlRead ($Input1) If FileExists("contacts\"&$Input&".txt") Then ;The bit that finds the file and possible problem $Result = $Input & ".txt" $file = FileOpen($Result, 0) $info = FileReadLine ($file, 1) FileClose ($file) #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("Search Results", 197, 206, 192, 125) ; The results and the other place where the problem could be $Group1 = GUICtrlCreateGroup("Results:", 8, 8, 185, 193) $Edit1 = GUICtrlCreateLabel($info, 16, 24, 169, 169, -1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Else MsgBox(4096,"ERROR!", "Entry Not Found") StartScreen () EndIf EndSelect WEnd Exit EndFunc I did try the FileFindFirstFile command but didnt get anywhere Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Xenobiologist Posted November 9, 2006 Posted November 9, 2006 Hi, just to get you one step further: expandcollapse popup#include <GUIConstants.au3> #include <file.au3> Dim $name, $DOB, $ADD, $AGE, $PH Global $Result StartScreen() Func StartScreen() ; The Main Screen $Form1 = GUICreate("What Would You Like to do?", 271, 100, 192, 125) $Button1 = GUICtrlCreateButton("Add Entry", 8, 35, 81, 25) $Button2 = GUICtrlCreateButton("Search", 8, 67, 81, 25) GUICtrlCreateLabel("Add an Entry", 96, 40, 65, 25) GUICtrlCreateLabel("Search for someone", 96, 72, 99, 25) GUICtrlCreateLabel("To start; click on an option bellow.", 8, 8, 251, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 GUISetState(@SW_HIDE) AddEntry() Case $msg = $Button2 SearchNameGUI() EndSelect WEnd Exit EndFunc ;==>StartScreen Func AddEntry() ;Adds an entry to save to a .txt $Form1 = GUICreate("Add Entry", 162, 196, 192, 125) GUICtrlCreateLabel("Name:", 8, 8, 56, 17) $name = GUICtrlCreateInput("Name", 64, 8, 89, 21, -1, $WS_EX_CLIENTEDGE) $DOB = GUICtrlCreateInput("DOB", 64, 32, 89, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("DOB:", 8, 32, 56, 17) GUICtrlCreateLabel("Address:", 8, 104, 56, 17) $PH = GUICtrlCreateInput("Phone", 64, 56, 89, 21, -1, $WS_EX_CLIENTEDGE) $AGE = GUICtrlCreateInput("Age", 64, 80, 89, 21, -1, $WS_EX_CLIENTEDGE) GUICtrlCreateLabel("Phone:", 8, 56, 56, 17) GUICtrlCreateLabel("Age:", 8, 80, 56, 17) $ADD = GUICtrlCreateInput("Adress(s)", 8, 120, 145, 69, -1, $WS_EX_CLIENTEDGE) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE MsgBox(64, "", "Entry Sucessfully added!") GetInfo() GUISetState(@SW_HIDE) StartScreen() Case Else ;;;;;;; EndSelect WEnd Exit EndFunc ;==>AddEntry Func GetInfo() ;Writes the file that contains all the info on a contact $nme = GUICtrlRead($name) $do = GUICtrlRead($DOB) $p = GUICtrlRead($PH) $ag = GUICtrlRead($AGE) $ad = GUICtrlRead($ADD) If Not _FileCreate(@ScriptDir & "\"& $nme & ".txt") Then MsgBox(4096, "Error", " Error Creating/Resetting log. error:" & @error) EndIf $open = FileOpen(@ScriptDir & "\" & $nme & ".txt", 2) If $open = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWriteLine($open, $nme) FileWriteLine($open, $do) FileWriteLine($open, $p) FileWriteLine($open, $ag) FileWriteLine($open, $ad) FileClose($open) EndFunc ;==>GetInfo Func SearchNameGUI() ;the search GUI #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("Search", 200, 40, 192, 125) $Input1 = GUICtrlCreateInput("Name", 8, 8, 113, 21, -1, $WS_EX_CLIENTEDGE) $Button1 = GUICtrlCreateButton("Search!", 128, 8, 65, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button1 GUISetState(@SW_HIDE) $Input = GUICtrlRead($Input1) If FileExists(@ScriptDir & "\" & $Input & ".txt") Then ;The bit that finds the file and possible problem $Result = $Input & ".txt" $file = FileOpen($Result, 0) $info = FileReadLine($file, 1) FileClose($file) #include <GUIConstants.au3> ; == GUI generated with Koda == $Form1 = GUICreate("Search Results", 197, 206, 192, 125) ; The results and the other place where the problem could be $Group1 = GUICtrlCreateGroup("Results:", 8, 8, 185, 193) $Edit1 = GUICtrlCreateLabel($info, 16, 24, 169, 169, -1) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;;;;;; EndSelect WEnd Exit Else MsgBox(4096, "ERROR!", "Entry Not Found") StartScreen() EndIf EndSelect WEnd Exit EndFunc ;==>SearchNameGUI So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now