Jump to content

how to put a text file into alpha order?

Recommended Posts

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


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.")




Do ;establish counter

$a = $a + 1

$b = FileReadLine($file)

If @error = -1 Then ExitLoop

until 2=1


$counter = $a

$a = 0

For $d = 1 to $counter

$file = FileOpen("c:\emaillist.dat", 0)

$file1 = FileOpen("c:\emaillist.txt", 2)


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





GUICtrlSetData($line1, $d)





GUICtrlSetData ($line3,$d / $counter)


As you can see my coding is very barbaric but usually works well.... when I'm not brain farting anyway..

Link to comment
Share on other sites

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...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...