'Sort'  -  Database Sorting Program








***   Written by  Dr Jason Wolfe   ***

Copyright     ©    Jason Wolfe   1993-2001     (Version 1.18)


[ Compatible with Psion Series 3a & 3c. (Not Series 3). ]

Updates of this program are available on-line at   http://www.jwolfe.clara.net






     Download Sort Package now ...



Sort OPL File  +  Dummy File  +  Help File  (Zip File).



     Some Sample Screenshots ...


Sort Screen 1
Sort Screen 2

    

'Register'  this  program.







Boring Legal Message



This Program is distributed as 'Shareware' - This means it may be freely copied and distributed.  However if you find the program useful, you are REQUIRED to  register  yourself as a user of the program, and INVITED to contribute an appropriate registration Fee.  The registration fee is not compulsory and is basically what you think the program is worth.

Registration entitles you to free technical support and upgrades.  If you have any genuine questions about this program or need any alterations made, I am contactable by email using the address above.  For major alterations or rewrites I may charge a suitable 'Consultation Fee'.  Please DO contact me to  register , even if you do not intend paying, as I am anxious to find out how many people are out there using my program.

You may not change ANY part of this program or use ANY part of it in any other products without my express permission. The program must be distributed in its entirety, with the 'help' file and 'dummy' file included. This Program is Not Public Domain.

Finally, this program is supplied as is. I cannot be held responsible for computers crashing, people dying, the world ending, and the like.  You use the program at your own risk.  All I know is that it works on my Psion fine, has proved very useful, and has never damaged anything.





WHAT THE PROGRAM DOES :



The Program takes a Data File in any format, and sorts it.

What did you expect !!

However, there are some advanced sorting options available, and
you can sort according to Name, Number or even Date.  In addition, unlike many other sorting programs available, it is able to sort a file according to 'Surname' rather than just 'First name'.  I much prefer this option when sorting my address books.






RUNNING THE PROGRAM :



On running the program, you are presented with a standard Psion Dialogue Box from which you can make various choices.

Choose the file to sort using the cursor keys.  You can also navigate around the filing system to choose files in different directories by pressing <Tab>.


The  'Sort by'  option has 4 options:
1.  Sort by  'First Name'  is a standard alphabetical sort.
2.  Sort by  'Surname'  will search each record for the last word in the line and use that word as the basis for the alphabetical sort.

Note that with hyphenated double-barrelled surnames, it is the first of the two names which is used as the word for sorting.  Secondly, where someone has a 'preferred name' rather than their real name, I place this in the 'Data' file entry in brackets after the true surname.   Eg. Paul Gascoigne (Gazza).  It is the true surname, not the preferred name which is used for the sort. 
If there is only one name in the line, then thats what it will sort !
3.  Sort by  'Number'  will do a numerical sort on the Data file in question.  The default option here is ascending numerical sort - ie. 1, 2, 5, 7, 9.

The only thing to remember when entering your numbers into the Data file, is to enter 'zero' as '0'.  If mistakenly enter enter a number as the capital letter 'O', then the program will get confused.
4.  Sort by  'Date'  will sort the records into ascending 'Chronological Order'.

The Date should take the form 'Day.Month.Year', for example 25.9.94 or 25.9.1994.   As I have shown, the year can be just the last two numbers (94) or the whole year (1994).  The date divider can be any non-numerical character - usually a full stop (.) or a slash (/), but theoretically it can be anything you choose, for example 25.9.94, 25/9/94, or 25*9*94.  The program will not be able to sort dates in the format 25th Sept 1994.



Other Sorting Options :



Direction of Sort

The program will  'by default '  sort fields into alphabetical or ascending numerical or chronological order.  If you wish to sort the file into 'reverse' alphabetical / numerical / or chronological order this can be done by specifying 'Reverse Sort' on the start menu.  This is not an advanced  'Reversed Sort calculated on the screen as you go' , since this is technically very difficult due to limitations in the OPL programming language.  It merely reverses the order of the data file once it has finished sorting it in the normal way.

Number of Field

Since the Word / Number / Date may not always be in the top field of the database entry, you can choose which field to carry the sort out on.   This is shown in the dialogue box as the  'Number of Field'.  If the object you want to sort is in the second field down, you would change the 'Number of field' to '2'.

Number  /  Date Prefix

The  'Number'  or  'Date'  used for the sort can be can be preceded by a letter or word 'prefix'.  This is useful because you can then keep more than one number or date on a single line in the 'Data' file, and still be able to sort the file correctly to your requirements.

I am a doctor, and I keep my patients' records on my Psion.  Part of the record involves putting the  'Date of Admission'  and  'Date of Discharge' in the record. I am able to put both of these in one line by preceding the date of admission by an  'A' and the date of discharge (Home) by an  'H'.   These letter prefixes allow me to sort my patients into the order they were admitted or discharged.  Why would I ever want to do this, I don't know, but I could do it if I wanted to!

Numbers can be preceded by letter or word prefix in the same way as above.   An example of its use could be if you were doing the ISIS Trial.  You might choose to give your patients reference numbers going like : Isis001, Isis002, Isis003...  or  just : I001, I002, I003, I004... You would enter the patients' details as normal, and when you were finished, you could sort them into ascending order of reference number.

Please note that if you are not using a prefix, then the reference number should be the FIRST item on the line.  The number may be followed by any string you want.





INSTALLING THE PROGRAM



Transfer the file 'sort/opl' to the OPL Directory on your Psion using whichever transfer program you have.  On PC's this will be 'PsiWin', on Macintosh's it will be 'PsiMac', and on Acorns it will be 'PsiRisc' or the 'A-Link'.  It is also suggested that you also transfer the file named 'Dummy/dbf' to the DAT Directory on your Psion, since this is a suitable file on which to carry out sorting operations.

Once the file is loaded onto the Psion, view the file in the OPL Program editor.  Before being able to run the program, you will need to 'Translate' the file into a OPL 'run' file.  This is very easily achieved by pressing <Psion-T>, or you could also select translate from the program menu.  This will create a new version of the program which the Psion can 'run' - It may take a minute or so for translation to be finished.  Finally, once it is finished you will be able to run the program.

The program is set up so that it should immediately be able to work on the attached 'Dummy/dbf' file, and it is suggested that you try out the program on this file as an experiment. However, any file should really be fine.

Note that the Dummy file contains the details of 50 patients with real diagnoses, but all identifiable information such as names, hospital numbers and dates of birth have been changed to protect their identities.



CUSTOMISING THE PROGRAM



If there is a file which you sort all the time, and you hardly ever sort any other files, then you can set up the program to sort that file by default and also change the sorting options to the ones you always use.

You will need to go into the program editor and change a few variables.  The variables are all found between the two sets of  ******** Asterisks ******** 's  close to the beginning of the file.

Change all the details as necessary and when finished, you will need to translate the program again into run code.  This is done by pressing <Psion T> as explained above in the section on installation.   Once this is done, the customisation process is complete and you will be ready to sort your files again.

The following section is a direct copy of the OPL programming code, so you will be able to see what you will need to change in the actual OPL file for customisation.  Every aspect which will ever need to be customised can be found between the two sets of asterisks.  I wouldn't advise changing anything else in the program unless you are an experienced programmer, and besides, it is against my copyright!

Here follows the OPL section :-
REM ********************************************************************

The Default Filename

file$="Dummy"


Adds the File Suffix and Sets the Default Location where Files are
Found.  Only change the Default Path if you know how - Consult the
Manual.
file$=file$+".dbf"
SETPATH "M:\Dat\"

Default Sorting Option
(1 = First Name/Word. 2 = Surname. 3 = Number 4 = Date)

sort%=2


Default Sort Direction (1 = Forward. 2 = Reverse)

direc%=1


The Default Field which will be used for Sorting

field&=1


The Default Number/Date Prefix (Only necessary for Numerical/Date
Sorts).  Leave this option null ("") if you don't want a default prefix.

prefix$=""

REM ********************************************************************




HINTS & TIPS

1. To break out of the Program while it is running: Press <Psion Esc>.
2. The program 'ought' to work on the Psion Siena, but I have not tested it on this.





TROUBLESHOOTING

1. If there is an error of Layout relating to the sort, then the Program will stop and advise you what type of error has occurred and, if appropriate, the name of the entry to which the error applies.  You should then correct the entry as appropriate.
2. Each individual Psion Series 3a or 3c 'Data' record can be up to exactly 4K long.  The maximum length of record for the Psion Series 3 was 1K.   Similarly, the maximum length of a single line in a Series 3a & 3c record is 1K.  The maximum length of a line on the Series 3 was 256 bytes or characters (a quarter of 1K).

Psion in their infinite wisdom forgot to update the OPL programming language to allow for these increases in record size.  This means that if you try to access a Data file which has any record greater than 1K in length using standard OPL routines, or any line which is longer than 256 bytes, the OPL program will crash.

If the record is longer than 1K, the error flashed on the screen is 'Record too long'.  If this is the case, I cannot even access the file at all - the OPL programming routines won't allow me to do so.  There are ways around this by using machine code and direct file access, but I don't have access to these methods because I don't have the 'Psion Developers Toolkit', which costs 200ukp.  You will just have to search through your Data file for records which seem to be too long and shorten them.

If a line on the record is greater than 256 characters long, then the error flashed on the screen is 'String too long'.  Here, the operating system does allow me to access that particular file, so I can tell you which is the offending record.  The solution is to go back to your 'Data' file and shorten that particular line of the offending record.

Fortunately, these errors are very rare under normal Psion use.
3. This program does not intrinsically suffer from the 'Millennium bug'. However, if you store your dates using only 2 digits (98) rather than 4 (1998) (and its up to you if you do!), then a 'sort by date' which which has entries on both sides of the millennium will get it wrong.  If you use 4 digits, it will get it right.
5. IMPORTANT NOTE :

When sorting a file, please ensure that there is at least an equal amount of free memory as the length of the file you are sorting, on the disk that the file is on.  This is to do with the way this program sorts the file: Every entry which is sorted is appended to the end of the file, extending its length.  The file is only compressed when the sort is finished.  If the Psion runs out of memory in the middle of a sort, then the sort will fail.



MY OWN IDEAS FOR IMPROVEMENTS



1. Improve the GUI  (Graphical User Interface).
2. Activate the 'help' key within the program.
3. Allow hierarchical sorts with multiple fields.
4. Sort the file using 'direct access' rather than OPL subroutines, which will bypass the '1K / Record'  &  '256bytes / Line'  limitation

Related Programs



Listpat Patient Listing Program  -  Produces ward-round printouts.

Match Patient Auditing Program  -  Criteria based searches.




Thats all.  Happy sorting.

(Please send all bug reports and suggestions to my email address).


©  Dr. Jason Wolfe (1993 - 2001)




PostBox   To contact me : Email  

WebPic    My Website is at   http://www.jwolfe.clara.net.  You're already there !!

Top     Back to  Top of Homepage


   Last Modified : 31st March 2001