Author: Kevin Jessup August 20, 1990 The following three programs make up a very useful directory sorting utility. Note that they are based on the infamous and painfully slow bubble sort algorithm. If you have a large directory, the programs may take a couple of minutes to execute. It still is a lot faster that sorting your directory manually. Hope you like them! Kevin Jessup 9118 N. 85th St. Milwaukee, WI 53224 Office: (414) 362-2020 Home: (414) 355-9752 ******************************************************************************** File name: VLPARSE Bytes: 184 Ckecksum: 9754 (HEX) Function: VLPARSE will take a list of variables and either delete or save all variables of a given type from that list. Inputs: Level three: LIST of variables Level two: object type (see page 97 of manual) Level one: 0 (to save the variables) or 1 (to delete the variables) Outputs: The parsed LIST. Example 1: 1) From your top level directory, execute the VARS command. 2) A list of variables should now be on the stack. 3) Enter 15 on the stack (this specifies a directory object). 4) Enter 0 on the stack (this tell VLPARSE to save all occurences of the object). 5) Execute VLPARSE. 6) A list of all directory objects remains on the stack. Example 2: Get a list of all variables in the current directory that do NOT contain PROGRAM objects. 1) Execute the VARS command. 2) Enter the real number 8 (specifies a program object). 3) Enter the real number 1 (delete variables of specified type). 4) Execute VLPARSE. 5) A list of all variables in the current directory that are NOT program objects remains on the STACK. If all objects in the current directory WERE program objects, the list is empty. Program Listing: %%HP: T(3)A(D)F(.); \<< { } \-> l t d n \<< IF l SIZE DUP THEN 1 SWAP FOR i 'l' i GET IF VTYPE t == d XOR THEN n 'l' i GET 1 \->LIST + 'n' STO END NEXT ELSE DROP END n \>> \>> ******************************************************************************** File name: ALPHSORT Bytes: 154 Checksum: E915 (HEX) Function: Sort a list of variables alphabeticly. This is the same bubble sort function that is on page 561 of the manuals except that a string conversion is performed on the list objects before the comparison. The bubble sort is probably the slowest of the numerous sorting routines available. If anyone has seen an implementation of the shell sort or quick sort algorithms on an HP48SX, please let me know! Right now I have neither the time nor the inclination to implement them. Inputs: List of objects on level one. Outputs: Alphabeticaly sorted list. Program listing: %%HP: T(3)A(D)F(.); \<< DUP SIZE 1 - 1 FOR j 1 j FOR k k GETI \-> n1 \<< GETI \-> n2 \<< DROP IF n1 \->STR n2 \->STR > THEN k n2 PUTI n1 PUT END \>> \>> NEXT -1 STEP \>> ******************************************************************************** File name: DSORT (Directory SORT) Bytes: 101.5 Ckecksum: ED34 (HEX) Function: DSORT will sort a directory alphabeticly. Sub-directores will be sorted first, followed by all other objects. Note that DSORT calls the above two progams as subroutines. Inputs: None Outputs: The current directory is sorted. The actual variables within the subdirectories are NOT sorted. Program listing: %%HP: T(3)A(D)F(.); \<< VARS 15 0 VLPARSE ALPHSORT VARS 15 1 VLPARSE ALPHSORT + ORDER \>> ***********************************[END]****************************************