Computer Science Canada Help with my almost done GUI Prog

Author:  Coog03 [ Sun Jun 15, 2003 12:15 am ]
Post subject:  Help with my almost done GUI Prog

Well I have got my GUI program working pretty good, ?I would appreciate any help in making this program any better.

Here is the code you'll have to create a names.txt file and a temp.txt file as well as change the path to the files.

Author:  JSBN [ Sun Jun 15, 2003 9:38 am ]
Post subject:

 code: put : temp, repeat ("-", 30) + "Book #", entrynum , repeat ("-", 30)

Is giving me brobelems as entrynum has not been declared

 Author: Coog03 [ Sun Jun 15, 2003 11:56 am ] Post subject: Yeah I was trrying to work out a way to use an array of records to keep track of the entry number so I coiuld possibly have a delete feauture.. Forgot to take thatr piece of code out, if anyone knows how to keep track of the entry number tell me...just take that part out, keep the dashed lines tho

 Author: Andy [ Sun Jun 15, 2003 3:11 pm ] Post subject: u should attatch something as long as this instead of wasting bandwith

 Author: Coog03 [ Sun Jun 15, 2003 9:40 pm ] Post subject: ok thats sweet, now I have to figure out how to take the contents of the file and sort it by whatever field the user wants...and by tomorrow morning (its 10:11pm) here any help on this prob

Author:  PaddyLong [ Sun Jun 15, 2003 10:03 pm ]
Post subject:

do you know any sort algorithms?

probably the most common (and easiest to understand) one is something like this...
 code: var somearray : array 1 .. 10 of int var temp : int %load some random values into the array for q : 1 .. 10     somearray (q) := Rand.Int (0, 100) end for %the actual sorting.. %essentially compares each element of the array with each element occuring after it for q : 1 .. 10     for w : q + 1 .. 10         if somearray (w) >= somearray (q) then %if the element after it is greater than it             temp := somearray (q) %store what was at position q (the lower value in this case)             somearray (q) := somearray (w) %move element w (greater value) to position q             somearray (w) := temp %put what was at position q (lower value) into position w         end if     end for end for %output the now sorted array for q : 1 .. 10     put somearray (q) end for

also I am pretty sure that you can check if a string is greater than another one as well (probably looks at the ascii reference values)

Author:  Coog03 [ Sun Jun 15, 2003 10:09 pm ]
Post subject:

I'm using a bubble sort thats the only one I know
 code: procedure Sort var n := upper (Data)     for i : 1 .. n - 1         var sorted := true         for decreasing j : n - 1 .. i             if Data (j).title > Data (j + 1).title then                 const temp := Data (j);                 Data (j) := Data (j + 1);                 Data (j + 1) := temp                 sorted := false             end if         end for         exit when sorted     end for        end Sort

I can't get it to take the values from the file sort them and output them into a file.

I tried using read / write but how do I put that text into a text box? if not I'll use the pu / get combo...this is due tommorrow and having it done by then would be good

Author:  PaddyLong [ Sun Jun 15, 2003 10:25 pm ]
Post subject:

read and write uses binary... so each of the strings you are reading must have a specified length

then you just do something like
 code: var Data : flexible array 1 .. 0 of     record         title : string (30)         firstname : string (25)         lastname : string (25)         value : string (10)         genre : string (15)         keyword : string (10)         subject : string (20)     end record procedure readFile     var file : int     var currIndex : int := 1     open : file, "somefile", read     loop         exit when eof (file)         new Data, currIndex         read : file, Data (currIndex)         currIndex += 1     end loop end readFile procedure writeFile     var file : int     open : file, "somefile", write     for q : 1 .. upper (Data)         write : file, Data (q)     end for end writeFile

of course if you wanted to switch to read/write from an ascii database, you would need to write up a quick program that takes in all of the things from your current database using get and then rewrite them using write

 Author: Coog03 [ Sun Jun 15, 2003 10:37 pm ] Post subject: got any idea on how to sort using your method of reading and writing

 Author: PaddyLong [ Sun Jun 15, 2003 10:48 pm ] Post subject: that method will just load it into your array as regular text... it will just be binary in the file so just like check Data(someindex).title or whatever instead of somearray(someindex)

 :