wizzardking Posted April 1, 2007 Posted April 1, 2007 Ok, heres the situation, I'm creating a mailing list by letting people comeup to a computer at a show and enter thier email address into an input box, then the program writes the email address to a standard textfile using filewriteline etc etc.. So now I got this huge email database (about 500 names not that huge eh) and I want to put it into alpha order, but not just displyed if read into an array but actually rewrite the file in alpha order.. When I started this I thought this will be easy I did this in like 6th grade with trsbasic.. (Ok showing my age) but now I can't figure out the logic loop to save my life.. PLEASE HELP!! Here's the sloppy code I have so far... #include <GUIConstants.au3> $a =0 GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUISetHelp("notepad") ; will run notepad if F1 is typed Opt("GUICoordMode",2) GUICtrlCreateLabel ("Email", 10, 30, 50) ; first cell 50 width $line1 = GUICtrlCreateInput ("", 0, -1, 300, 20) GUICtrlCreateLabel ("Done", -350, 0) ; next line $line2 = GUICtrlCreateInput ("", -250, -1, 40, 20) $line3 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH) GUISetState () ; will display an empty dialog box $file = FileOpen("c:\emaillist.dat", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $a=0 Do ;establish counter $a = $a + 1 $b = FileReadLine($file) If @error = -1 Then ExitLoop until 2=1 FileClose($file) $counter = $a $a = 0 For $d = 1 to $counter $file = FileOpen("c:\emaillist.dat", 0) $file1 = FileOpen("c:\emaillist.txt", 2) EndIf For $a = 1 to $counter $b = FileReadLine($file) If @error = -1 Then ExitLoop $line = FileReadLine($file) GUICtrlSetData($line2, $a) If $b > $line then $c = $b $b = $line $line = $c EndIf FileWriteLine($file1,$ FileWriteLine($file1,$line) Next GUICtrlSetData($line1, $d) FileClose($file) FileClose($file1) FileDelete("c:\emaillist.dat") FileMove("c:\emaillist.txt","c:\emaillist.dat") GUICtrlSetData ($line3,$d / $counter) Next As you can see my coding is very barbaric but usually works well.... when I'm not brain farting anyway..
xcal Posted April 1, 2007 Posted April 1, 2007 _FileReadToArray() _ArraySort() _FileWriteFromArray() How To Ask Questions The Smart Way
wizzardking Posted April 3, 2007 Author Posted April 3, 2007 _FileReadToArray()_ArraySort()_FileWriteFromArray()OMG duh.. like i said brain farting.. thanx i'll work it this week!
Maxtreeme Posted April 3, 2007 Posted April 3, 2007 well to sort it alphabetically if the addresses are entered at different intervals, not all at once, you have to rewrite the file containing them from time to time with what xcal wrote.
wizzardking Posted April 5, 2007 Author Posted April 5, 2007 well to sort it alphabetically if the addresses are entered at different intervals, not all at once, you have to rewrite the file containing them from time to time with what xcal wrote.actually the files will be on several computers then we merge them after the events and then need them in alpha order so we would have a complete dbase to work with. and it worked like a charm too!! Thanx a bunch all...
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