Dealing with a bug in the sort routing

Authors

Robert Fischer

Publication

Publication Details

Issue: 3

Date

 

Pages

1
See all articles from Extensions issue 3

First lets deal with a bug I found in the machine code sort routine. There is one situation when this routine will lock up the computer. If you sort by a line which will in some cases be the last line of the file and in other cases will not AND the line you sort by will have the same information in some files, the possibility exists for a crash. When the last line of one file is compared to a line which is not the last line of another and the information in the lines is identical the routine will eventually come to an end of line marker (code 1) in one case and the start of a new file marker (code 42) in the other. The routine locks up when this happens. I do not Know enough about the routine to fix it, but it can be avoided. Either donโ€™t allow any identical information to be on the last line of any files, or put dummy information in a later line so the last line is moved down.

I chose the second option with my music list files. Originally the first line was the title, second was the composer, third was the difficulty level, and if I owned it there was a fourth line for the library number. Since the difficulty level in line 3 would often be the same and some files had 3 and others four lines, I added a period to make a fourth line in all 3 line files. This used 2 bytes of memory for each affected file (1 for the period and one end of line marker). With my UPDATE routine from issue #2, this was easy to do!

Products

Downloadable Media

 
Scroll to Top