0010 ! SORTLEX (i.e. SORTX1A) is a LEX file from CHHU-IT. 0020 ! This LEX file was presented at the Copenhagen conference, August 1987, and it will be 0030 ! part of future versions of JPCLEX. A forthcoming article will describe SORTLEX in detail. 0040 ! This sample program means to be a quick reference guide. 1000 DISP IMG$("Filename") 1010 ! return a string of "A"s and "D"s representing a DATA file's field data type. 1020 DISP IMG$("Filename",N) 1030 ! Same as before, but with respect to the specified record, (N). 1040 DISP LENREC("Filename") 1050 ! Return length of DATA record in number of bytes. 1060 DISP RECORDS("Filename") 1070 ! Return number of records in file. 1080 DISP ROOM("Filename") 1090 ! return number of empty records at end of file. 1100 GROW #C,N 1110 ! Increase a DATA file's size by the specified number of records. 1120 MOVE #C FROM S TO D 1130 ! Move record from Source position to Destination position. 1140 ERASE #C FROM S TO E 1150 ! erase the records between record S and record E. 1160 ! 1170 ! The following statements will sort a DATA file. 1180 ! ASCSORT performs an ASCII ordered sort. 1190 ! LEXSORT performs a lexicographical ordered sort. 1200 ! The two statements have otherwise exactly the same syntax and options. 1210 ! The following examples will be given using LEXSORT. 1220 LEXSORT #C 1230 ! Sort whole file in ascending order; the first field of 1240 ! every record is taken as the key field. 1250 LEXSORT #C FROM S 1260 ! Same as before, but sort is limited to the lose block of records 1270 ! spanning from the Start record to the last record in the file. 1280 LEXSORT #C FROM S TO E 1290 ! Same as before, but limited to portion of file between Start and End records. 1300 ! Option: if Start > End, then the sort is performed in descending order. 1310 ! Example: 1320 LEXSORT #C FROM RECORDS("Filename")-1 TO 0 1330 ! This will give a descending ordered sort of the whole file. 1340 LEXSORT #C ON F1,F2,F3 ! [,...,F10] 1350 ! Perform sort on fields F1,F2,...,F10. 1360 ! Limitation: 1 <= Fn <= 15. 1370 ! The ON-clause can be used with FROM and TO as well: 1380 LEXSORT #C FROM S ON F1,F2,F3,F4 ! ... 1390 LEXSORT #C FROM S TO E ON F1,F2,F3 ! ... 1400 ! Now, how do you like this... 1410 LEXSORT #C FROM RECORDS("Filename") DIV 2 TO 0 ON POS(IMG$("Filename"),"A") 1420 ! That will sort the first half of a data file in descending order, 1430 ! taking the first alphanumeric field as the key field. 1440 ! 9000 ! SORTLEX, (c) 1987, by 9001 ! Stefano Tendon - Cantone Delle Asse 5 - 29100 PIACENZA - Italy 9002 ! Italo Panella - Via Raffaello Sanzio 20 - 20094 CORSICO (MI) - Italy