PcExpert Posted January 14, 2007 Posted January 14, 2007 Hello, Is it possible to make a program where users can search a database for a number and if that number is found then it displays a msgbox with the status of that number? a sample: A users runs check.exe A Inputbox is shown User puts in his number Program searches for that number in the database If the number exists it reads the next line with the status of that number and it then returns the status to the user by displaying a msgbox with the status. Thanks for your help!
BALA Posted January 14, 2007 Posted January 14, 2007 Do you already have the database, or are you trying to find a way to search through it? [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
PcExpert Posted January 14, 2007 Author Posted January 14, 2007 (edited) I already have a database I only need the to know how to search throught it. Edited January 14, 2007 by PcExpert
PcExpert Posted January 15, 2007 Author Posted January 15, 2007 I searched in the helpfile. But I didn´t find anything, but I know that autoit can do it. Can somebody put me on the right way?
BALA Posted January 15, 2007 Posted January 15, 2007 Is the database in a text file, or INI file, because if so, you could just use on of the String functions to search through it. [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
BALA Posted January 15, 2007 Posted January 15, 2007 (edited) I think StringInStr() might work $result = StringInStr("I am a String", "RING") MsgBox(0, "Search result:", $result) $location = StringInStr("How much wood could a woodchuck chuck is a woodchuck could chuck wood?", "wood", 0, 3) ; Find the 3rd occurance of "wood" Edited January 15, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
jvanegmond Posted January 15, 2007 Posted January 15, 2007 Show us part of the TXT file. You need to parse the database in such a way so that you can find stuff by Index. A few lines should be enough. github.com/jvanegmond
PcExpert Posted January 15, 2007 Author Posted January 15, 2007 (edited) This is 1 problem registred in the database. Name:TestProblem: Computer doesn't startCode: 56891---------------------------With the code I want users to be able to check the status of there problem. So users open a program input there problem code and then it returns the status of the problem with the code specified. Edited January 15, 2007 by PcExpert
jvanegmond Posted January 15, 2007 Posted January 15, 2007 So the database looks like this CODEName:Test Problem: Computer doesn't start Code: 56891 Name:Test Problem: Computer doesn't start Code: 56891 Name:Test Problem: Computer doesn't start Code: 56891 Name:Test Problem: Computer doesn't start Code: 56891 Name:Test Problem: Computer doesn't start Code: 56891 Name:Test Problem: Computer doesn't start Code: 56891 github.com/jvanegmond
PcExpert Posted January 15, 2007 Author Posted January 15, 2007 (edited) Thats right with a line like this: ---------------------------------after each problemSo it looks like this: Name:TestProblem: Computer doesn't startCode: 56891---------------------------------Name:TestProblem: Computer doesn't startCode: 56891 ---------------------------------Name:TestProblem: Computer doesn't startCode: 56891 ---------------------------------Name:TestProblem: Computer doesn't startCode: 56891 --------------------------------- Edited January 15, 2007 by PcExpert
jvanegmond Posted January 15, 2007 Posted January 15, 2007 That makes things a lot easier. github.com/jvanegmond
jvanegmond Posted January 15, 2007 Posted January 15, 2007 (edited) Next time, give more information on what you want. You mentioned 'a' database, it could have been anything! Never make others have to find out how to help you.#include <Array.au3> $Read = FileRead("Database.txt") While StringInStr($Read,"--") $Read = StringReplace($Read,"--","-") WEnd $Database = StringSplit($Read,"-") _ArrayDisplay($Database,$Database[0]) $i = InputBox("","Code?") For $x = 1 to $Database[0] If StringInStr($Database[$x],$i) Then MsgBox(0,"Database", $Database[$x]) EndIf Next Edited January 15, 2007 by Manadar github.com/jvanegmond
PcExpert Posted January 15, 2007 Author Posted January 15, 2007 Thanks! If I start it I first get a msgbox displaying: [0]= 5 [1] = Name:Test Problem: Computer doesn't start Code: 56891 [2] = Name:Test Problem: Computer doesn't start Code: 36271 [3] = Name:Test Problem: Computer doesn't start Code: 54927 [4] = Name:Test Problem: Computer doesn't start Code: 22519 [5] = Can I get rid of that? So it only displays the second msgbox with the info?
jvanegmond Posted January 15, 2007 Posted January 15, 2007 I forgot to remove it, I used it for testing purposes. $Read = FileRead("Database.txt") While StringInStr($Read,"--") $Read = StringReplace($Read,"--","-") WEnd $Database = StringSplit($Read,"-") $i = InputBox("","Code?") For $x = 1 to $Database[0] If StringInStr($Database[$x],$i) Then MsgBox(0,"Database", $Database[$x]) EndIf Next github.com/jvanegmond
jvanegmond Posted January 15, 2007 Posted January 15, 2007 Only because you're dutch and joined on my birthday. I hope you make good use of it. github.com/jvanegmond
PcExpert Posted January 15, 2007 Author Posted January 15, 2007 I wait one question: How to display a msgbox if the number is not found? This is what I tried: #include <Array.au3> $Read = FileRead("Database.txt") While StringInStr($Read,"--") $Read = StringReplace($Read,"--","-") WEnd $Database = StringSplit($Read,"-") $i = InputBox("","Probleemcode invoeren A.U.B.") For $x = 1 to $Database[0]If StringInStr($Database[$x],$i) Then MsgBox(0,"Database", $Database[$x]) Else Msgbox(64, "Database", "Number not found.") EndIf Next then it displays the msgbox 3 times or so if the number is not found I want it to just show once.
jvanegmond Posted January 15, 2007 Posted January 15, 2007 (edited) $Read = FileRead("Database.txt") While StringInStr($Read,"--") $Read = StringReplace($Read,"--","-") WEnd $Database = StringSplit($Read,"-") $i = InputBox("","Probleemcode invoeren A.U.B.") For $x = 1 to $Database[0] If StringInStr($Database[$x],$i) Then MsgBox(0,"Database", $Database[$x]) Exit EndIf Next Msgbox(64, "Database", "Number not found.") Now if the number is found it quits before the "Number not found" msgbox is shown. You can delete the INclude. Edited January 15, 2007 by Manadar github.com/jvanegmond
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