home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / asm / RPSRT102.ZIP / EXAMPLES.DOC < prev    next >
Encoding:
Text File  |  1991-10-10  |  33.3 KB  |  759 lines

  1.  
  2.  
  3.   October 10, 1991             RPSORT Examples                       Page   i
  4.  
  5.                               Table of Contents
  6.                               -----------------
  7.  
  8.   Suggestion On How To Use This Document                                    1
  9.   General Rules For Entry Of Parameters And Description Of Parameter Types  1
  10.   Cautionary Note On Specifying The Output File To RPSORT                   1
  11.  
  12.   Examples That Could Be Executed By The DOS SORT                           2
  13.     1. RPSORT As A Filter                                                   2
  14.     2. Sending Output To The Screen                                         2
  15.     3. Specifying A Sort Key                                                2
  16.     4. Reverse (Descending) Sort                                            2
  17.     5. Using Pipes With RPSORT.                                             2
  18.  
  19.   Examples Of General Interest                                            3-8
  20.     6. Using RPSORT Not As A Filter                                         3
  21.     7. Fixed Length Records                                                 3
  22.     8. Multiple Input Files                                                 3
  23.     9. ASCII (Case Sensitive) Sort                                          3
  24.    10. Reverse (Descending) Sort                                            3
  25.    11. Reverse ASCII Sort                                                   4
  26.    12. Specifying Key Length                                                4
  27.    13. Specifying Key Length But No Start Column                            4
  28.    14. Multiple Sort Keys                                                   4
  29.    15. Another Example Of Multiple Sort Keys                                4
  30.    16. Sort DIR Listing With Multiple Sort Keys                             5
  31.    17. Make ASCII Sequence The Default                                      5
  32.    18. Make Reversed (Descending) Sort The Default                          5
  33.    19. Make Both ASCII And Reversed The Default                             6
  34.    20. Delete Null Lines                                                    6
  35.    21. Delete Lines/Records With Duplicate Keys                             6
  36.    22. Delete Lines/Records If They Are Completely Identical                6
  37.    23. Specify Drive For Temporary Files                                    6
  38.    24. Ignore Ctrl-Z And Use The Entire File                                7
  39.    25. Suppress Copyright And Successful Completion Messages                7
  40.    26. Put Error Messages In A File                                         7
  41.    27. Suppress Copyright Message And Put Error Messages In A File          7
  42.    28. Tell RPSORT To Ignore Any Ctrl-Break From The Keyboard               7
  43.    29. Expanding Tabs In A File                                             8
  44.  
  45.   Examples Of Special Interest To Computer Programmers                   9-11
  46.    30. C Language String As Sort Key                                        9
  47.    31. Mixing C Language Strings And Regular Strings                        9
  48.    32. Turbo Pascal String As Sort Key                                      9
  49.    33. Mixing Turbo Pascal Strings And Regular Strings                      9
  50.    34. Make C Language Strings The Default                                 10
  51.    35. Make Turbo Pascal Strings The Default                               10
  52.    36. Signed Binary Integer As Sort Key                                   10
  53.    37. Turbo Pascal String And Signed Binary Integer                       10
  54.    38. Unsigned Binary Integer As Sort Key                                 11
  55.    39. 80x87 Floating Point Number As Sort Key                             11
  56.    40. BASICA & GWBASIC Floating Point Number As Sort Key                  11
  57.    41. Turbo Pascal Real Number As Sort Key                                11
  58.  
  59.   List Of Various Compiler And Interpreter Numeric Data Types              12
  60.  
  61.  
  62.  
  63.   October 10, 1991             RPSORT Examples                       Page   1
  64.  
  65.  
  66.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  67.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  68.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  69.  
  70.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  71.  
  72.  
  73.   Suggestion On How To Use This Document
  74.  
  75.     In this document, I start with the simplest examples and build up to
  76.     examples that include several parameters.  Eventually every type of
  77.     parameter that RPSORT supports appears at least once.
  78.  
  79.     Many parameters are only described once or twice when they first appear 
  80.     in examples.  When they are used in later examples they may not be 
  81.     described.  Therefore, I suggest that the best idea would be to scan the 
  82.     examples in order rather than skipping around to topics of interest.
  83.  
  84.  
  85.   General Rules For Entry Of Parameters And Description Of Parameter Types
  86.  
  87.   . All parameters may be entered in upper or lower case as you choose.  As
  88.     far as RPSORT is concerned, there is no difference.
  89.  
  90.   . The parameters may be entered in any sequence except as noted in the
  91.     discussion of some RPSORT examples.
  92.  
  93.   . In the commands below, I separate the parameters with spaces for clarity.
  94.     RPSORT generally accepts spaces between parameters but does not require
  95.     them except as noted in the discussion of some RPSORT examples.
  96.     
  97.   . The syntax for RPSORT is simpler than the forbidding usage specification,
  98.     at the top, might suggest.  There are three kinds of parameters:
  99.  
  100.     .. Filespecs. For the input to RPSORT you can have either a single
  101.        filespec or a list of filespecs separated by plus signs.  For the
  102.        output only a single filespec is allowed.
  103.  
  104.     .. Switches.  These are a slash followed by a letter indicating the type
  105.        of switch.  Some switches also include a number, filespec or drive.
  106.  
  107.     .. Sort key definitions.  These are a slash followed by a plus sign 
  108.        ("/+") and one or more attributes which define a sort key.
  109.  
  110.  
  111.   Cautionary Note On Specifying The Output File To RPSORT
  112.  
  113.   . If you enter an output filespec, whose path and filename are the same as 
  114.     that for an existing file, the latter will be replaced by the output from 
  115.     RPSORT.  If this is what you want, fine, but if you don't want to lose 
  116.     the existing file then use a different name for the output.
  117.  
  118.  
  119.  
  120.   October 10, 1991             RPSORT Examples                       Page   2
  121.  
  122.  
  123.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  124.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  125.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  126.  
  127.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  128.  
  129.  
  130.   Examples That Could Be Executed By The DOS SORT
  131.  
  132.     The first five examples are commands that could be executed by DOS SORT
  133.     but RPSORT does them much faster and can do them for much larger files.
  134.  
  135.  
  136.     1. RPSORT is here used as a filter which is the only option for the DOS
  137.        SORT.  No sort key is defined, so the sort key is the entire line.
  138.        The default for RPSORT and the only option for the DOS SORT is that:
  139.  
  140.        . The input is a text file consisting of lines each ending with a CRLF
  141.          (i.e. a carriage return and a line feed.)
  142.        . The sort key is case insensitive.  Lower case letters sort equal to
  143.          upper case letters and foreign letters, punctuation and currency
  144.          symbols sort equal to their American English equivalents.
  145.  
  146.            RPSORT  <MYINPUT.DAT  >C:\MYSORTED.DAT
  147.  
  148.  
  149.     2. In this case, no output file is specified so output goes to the 
  150.        screen.  You must specify an input file for RPSORT.  Unlike the DOS 
  151.        SORT, it doesn't accept input data from the keyboard.
  152.  
  153.            RPSORT  <MYINPUT.DAT
  154.  
  155.  
  156.     3. The "/+12" sort key definition says that the sort key starts at column 
  157.        12 and consists of the rest of the line.  One sort key is listed which 
  158.        is all that the DOS SORT allows.
  159.  
  160.            RPSORT  /+12  <D:\MYDIR\INPUT.TXT  >D:\OTHERDIR\SORTED.DAT
  161.  
  162.  
  163.     4. The /R switch tells RPSORT to do a reverse (descending) sort.  The
  164.        sort key starts at column 23.
  165.  
  166.            RPSORT  /R  /+23  <DATA.TXT  >SORT.TXT
  167.  
  168.  
  169.     5. This sorts a DIR listing by the file extension (extension is at column 
  170.        10) and lists one page at a time.  The output of the DIR command is 
  171.        piped to RPSORT whose output is then piped to the MORE command.  The 
  172.        listing might include two strange file names.  These are temp files 
  173.        created by DOS to hold data being piped.
  174.  
  175.            DIR  C:\*.*  |  RPSORT  /+10  |  MORE
  176.  
  177.  
  178.  
  179.   October 10, 1991             RPSORT Examples                       Page   3
  180.  
  181.  
  182.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  183.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  184.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  185.  
  186.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  187.  
  188.  
  189.   Examples Of General Interest
  190.  
  191.  
  192.     6. RPSORT does not have to be used as filter.  The files maybe specified
  193.        without redirection.  Filespecs may include a path.  You must enter 
  194.        the input filespec first and the output filespec second.  Here, the 
  195.        sort key starts at column 4 and consists of the rest of the line.
  196.  
  197.            RPSORT  /+4  MYINPUT.TXT  D:\DATADIR\SORTOP.DAT
  198.  
  199.  
  200.     7. RPSORT can sort fixed length records.  The /F75 switch says that the
  201.        input consists of records each 75 bytes long.  It is not required that
  202.        the records end with a CRLF but if they do, the record length given by
  203.        the /F switch must include the two bytes for the CRLF.  The sort key
  204.        starts at column 13 and consists of the rest of the record.
  205.  
  206.            RPSORT  /F75  /+13  B:INPUT.DAT  SORTED.DAT
  207.  
  208.  
  209.     8. For the input, you can list muliple filespecs separated by plus signs.
  210.        No spaces are allowed between the input filespecs only plus signs.
  211.        RPSORT combines the input files and sorts them as one.  The combined
  212.        sorted output is then written to the single output file.  Wildcard
  213.        characters are allowed in input filespecs and all files with matching 
  214.        names will be included.
  215.  
  216.            RPSORT  INPUT1*.DAT+C:\MYDIR\INPUT2.DAT+INPUT?3.DAT  OUTPUT.DAT
  217.  
  218.  
  219.     9. Here, the sort key starts at column 7 of the 90 byte record.  This is 
  220.        an ASCII (case sensitive) sort as indicated by the A in the sort key
  221.        definition.
  222.  
  223.        The sequence is per the ASCII value assigned to each character.  This
  224.        puts the digits 0 through 9 before any letters and puts all of the
  225.        upper case letters before any of the lower case letters.
  226.  
  227.            RPSORT  /F90  /+7A  MY??INFO.DAT  SORT.DAT
  228.  
  229.  
  230.    10. The sort key starts at column 11 of the line.  It will be sorted in
  231.        the descending case insensitive sequence as indicated by the R in the
  232.        sort key definition.  This is also called a reverse sort.
  233.  
  234.            RPSORT  /+11R  MYIP.DAT  B:MYSORT.DAT
  235.  
  236.  
  237.  
  238.   October 10, 1991             RPSORT Examples                       Page   4
  239.  
  240.  
  241.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  242.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  243.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  244.  
  245.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  246.  
  247.  
  248.   Examples Of General Interest (continued)
  249.  
  250.  
  251.    11. The sort key starts at column 6 of the 60 byte record.  It will be
  252.        sorted in the descending ASCII (case sensitive) sequence as indicated
  253.        by the A and R attributes in the sort key definition.
  254.  
  255.            RPSORT  /F60  /+6AR  IP*.D?T  OP.DAT
  256.  
  257.  
  258.    12. Here, an ASCII sort key starts at position 11 of the line and is 7
  259.        characters long.  A colon followed by a number, in a sort key
  260.        definition, represents the length of the sort key.
  261.  
  262.            RPSORT  /+11:7A  B:DATA*.DOC  SORTDATA.DOC
  263.  
  264.  
  265.    13. The case insensitive sort key starts at column 1, by default, because
  266.        the starting column is not given in the sort key definition.  The key
  267.        is 9 bytes long.
  268.  
  269.            RPSORT  /F80  /+:9  INPUT.DAT  OUTPUT.DAT
  270.  
  271.  
  272.    14. You can list as many sort keys definitions, as you like, provided they
  273.        fit within the command line (maximum of 127 bytes).  The first sort
  274.        key is 6 bytes starting at column 13, the second is an 8 byte ASCII
  275.        key at column 1 and the third a 4 byte key at column 19.
  276.  
  277.        A sort involves comparing two lines at a time in order to sequence
  278.        them correctly.  RPSORT compares two lines by comparing the sort keys
  279.        in the same order as their listing in the command line.
  280.  
  281.        The first unequal compare, if any, determines the sequence of the two
  282.        lines.  If all the sort keys are equal then the lines are sequenced
  283.        per their positions in the input file.
  284.  
  285.            RPSORT  /+13:6  /+:8A  /+19:4  DATA1.TXT+DATA2.TXT  SORT.TXT
  286.  
  287.  
  288.    15. Another example of multiple sort keys this time for a fixed length
  289.        record.  The first sort key uses the descending ASCII sequence, the
  290.        second uses the case insensitive sequence and the third uses the
  291.        descending case insensitive sequence.
  292.  
  293.            RPSORT  /F50  /+15:3AR  /+4:7  /+21:9R  INPUT.DAT  SORTEDIP.DAT
  294.  
  295.  
  296.  
  297.   October 10, 1991             RPSORT Examples                       Page   5
  298.  
  299.  
  300.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  301.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  302.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  303.  
  304.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  305.  
  306.  
  307.   Examples Of General Interest (continued)
  308.  
  309.  
  310.    16. Here RPSORT is used as a filter with the input coming from a DIR
  311.        command and the sorted output going to a MORE command which displays
  312.        the output one screen at a time. The effect of the sort keys is to
  313.        sort the directory entries by creation date (first by year then by
  314.        month and day) and by file name and extension within creation date.
  315.  
  316.            DIR  D:\*.*  |  RPSORT  /+30:2  /+24:5  /+:12  |  MORE
  317.  
  318.        The listing might contain two strange file names.  These are temporary 
  319.        files created by DOS to hold the data being piped.
  320.  
  321.        If you have DOS 5.0 you don't need a sort utility to produce a sorted
  322.        directory listing.  Instead you can use the new "/O" switch.  The
  323.        following command achieves a similar effect as the previous one except
  324.        that it sorts on both the creation date and time:
  325.  
  326.            DIR  D:\*.*   /P   /ODNE
  327.  
  328.  
  329.    17. The /A switch tells RPSORT that both sort keys, in the example, are to
  330.        be sorted according to the ASCII sequence.  The first key uses the
  331.        regular ASCII sequence while the second sort key uses the descending
  332.        ASCII sequence as indicated by the R attribute.
  333.  
  334.        If you specify /A, there is no way to change it for an individual
  335.        sort key.  If you want some sort keys to be ASCII and some to be case
  336.        insensitive, don't use /A but instead specify A in the appropriate
  337.        sort key definitions.
  338.  
  339.            RPSORT  /F120  /A  /+19:4  /+3:9R  MYDATA.DAT  SORTDATA.DAT
  340.  
  341.  
  342.    18. The /R switch tell RPSORT to do a descending (reverse) sort for all
  343.        the sort keys.  The first key uses the descending ASCII sequence, as
  344.        indicated by the A attribute, while the second sort key uses the
  345.        descending case insensitive sequence.
  346.  
  347.        If you specify /R, there is no way to change it for an individual sort
  348.        key.  If you want some sort keys to be descending and some not, don't
  349.        use /R but instead specify R for the appropriate sort key.
  350.  
  351.            RPSORT  /R  /+12:8A  /+:11  IP.TXT  OP.TXT
  352.  
  353.  
  354.  
  355.   October 10, 1991             RPSORT Examples                       Page   6
  356.  
  357.  
  358.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  359.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  360.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  361.  
  362.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  363.  
  364.  
  365.   Examples Of General Interest (continued)
  366.  
  367.  
  368.    19. Here both /A and /R are specified.  This means that all three sort
  369.        keys will use the descending ASCII sequence.
  370.  
  371.            RPSORT  /F90  /A  /R  /+1:7  /+11:5  /+8:3  DAT1.DAT  SORT.DAT
  372.  
  373.  
  374.    20. The /N switch tells RPSORT to delete all null lines from the sorted
  375.        output file.  A null line contains only CRLF (a carriage return and a
  376.        line feed) and nothing else.  Lines that are all spaces and thus look
  377.        like null lines when you list them will NOT be deleted.
  378.  
  379.            RPSORT  /N  /+3:9  /+1:2A  INPUT.DOC  SORTED.DOC
  380.  
  381.  
  382.    21. The /D switch tells RPSORT to delete from the sorted output all
  383.        records whose sort keys duplicate those in a previous record.  This
  384.        will delete records that are not identical to a previous record
  385.        because all that is required is that the sort keys be the same.
  386.  
  387.            RPSORT  /F100  /D  /+14:7  /+4:10R  DATA.DAT  SORTED.DAT
  388.  
  389.  
  390.    22. If you want to delete lines/records only if they are identical to a
  391.        previous line/record, tack on /+A as the final sort key.  Since this
  392.        uses the entire line as an ASCII key, it means that the only time all
  393.        keys will be equal is when the lines are identical.
  394.  
  395.            RPSORT  /D  /+14:7  /+4:10R  /+A  DATA.TXT  SORTED.TXT
  396.  
  397.  
  398.    23. The /T switch tells RPSORT where to put any temporary files, it may
  399.        require.  In this case, /TC says to put them on the C drive.
  400.  
  401.        If the input file is small enough to fit into the available memory, it
  402.        is sorted in one pass and temporary files are not required.  Else,
  403.        RPSORT reads and sorts the file a chunk at a time and writes the
  404.        sorted chunks to a temporary file.  Then RPSORT does one or more merge
  405.        phases to combine the chunks into a single sorted output file.
  406.  
  407.        If the /T switch is not specified, RPSORT puts any temporary files on
  408.        the default drive.
  409.  
  410.            RPSORT  /TC  /+9:12A  /+23:11R  BIGINPUT.DAT  BIGSORT.DAT
  411.  
  412.  
  413.  
  414.   October 10, 1991             RPSORT Examples                       Page   7
  415.  
  416.  
  417.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  418.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  419.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  420.  
  421.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  422.  
  423.  
  424.   Examples Of General Interest (continued)
  425.  
  426.  
  427.    24. The /Z switch tells RPSORT to ignore any Ctrl-Zs in a text file and to
  428.        use the entire file.  Normally RPSORT, like DOS, stops reading when it
  429.        finds a Ctrl-Z in an input file.  This is usually O.K. since the
  430.        Ctrl-Z, if present, normally follows the last byte of actual data.
  431.  
  432.        However, if Ctrl-Zs appear in the middle of a text file then you must
  433.        use /Z to get RPSORT to sort the entire file.
  434.  
  435.            RPSORT  /Z  /A  /+1:5R  /+11:3  DOWNLOAD.DAT  SORTED.DAT
  436.  
  437.  
  438.    25. The /Q switch suppresses the display of the copyright message at the
  439.        beginning and the successful completion message at the end.  Error
  440.        messages, if any, will still be displayed.  This switch must be the
  441.        first parameter on the command line.
  442.  
  443.            RPSORT  /Q  /F40  /+12:3A  /17:4R  INPUT.DAT  OUTPUT.DAT
  444.  
  445.  
  446.    26. The /E switch, in this example, tells RPSORT to create the file
  447.        MYERRORS.TXT and to direct any error or successful completion
  448.        messages to that file.  Except for the /Q switch, no other parameter
  449.        should precede this switch in the command line.
  450.  
  451.        Since the /Q switch was not specified in this example, the copyright
  452.        message will still appear on the screen.  Any error or successful
  453.        completion messages, if appropriate, will be sent to MYERRORS.TXT.
  454.  
  455.            RPSORT  /EMYERRORS.TXT  /2:9AR  DATA.TXT  SORTED.TXT
  456.  
  457.  
  458.    27. This example suppresses copyright and successful completion messages
  459.        and sends any error messages to the file SORTERR.DAT.
  460.  
  461.            RPSORT  /Q  /ESORTERR.DAT  /2:9AR  DATA.TXT  SORTED.TXT
  462.  
  463.  
  464.    28. Normally, RPSORT responds promptly to a Ctrl-Break from the keyboard
  465.        and lets you terminate the sort.  The /B switch, however, tells RPSORT
  466.        to ignore Ctrl-Break and to continue with the sort until it is done.
  467.  
  468.            RPSORT  /B   /4:13R   IP.DAT   OP.DAT
  469.  
  470.  
  471.  
  472.   October 10, 1991             RPSORT Examples                       Page   8
  473.  
  474.  
  475.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  476.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  477.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  478.  
  479.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  480.  
  481.  
  482.   Examples Of General Interest (continued)
  483.  
  484.  
  485.    29. If the input file contains tabs, they may need to be expanded to the
  486.        proper number of spaces to properly align your sort keys.  RPSORT 
  487.        can't sort such a file correctly because it doesn't expand tabs.
  488.        
  489.        As a convenience, I have included a program called RPTAB.  It reads 
  490.        your file and produces an output file that is the same except that the 
  491.        tabs have been expanded.  The syntax is:
  492.  
  493.            RPTAB  input-filespec  output-filespec  [tabstop...]
  494.  
  495.        The parameters must be given in the order defined above.  Listing tab 
  496.        stops is optional.  If you specify none, the default tab stops are at
  497.        positions 1, 9, 17, 25, 33... and so on at intervals of eight columns.  
  498.        
  499.        If you specify tab stops they must be a sequence of integers each 
  500.        greater than the preceding one.  The first tab stop is always column 1 
  501.        and need not be given.  The interval between the last two explicit tab 
  502.        stops implies subsequent tab stops at equal intervals.
  503.  
  504.        The following command expands tabs to the default tab stops:
  505.  
  506.            RPTAB   MYTABS.DAT   MYSPACES.DAT
  507.  
  508.        The following command:
  509.  
  510.            RPTAB   MYTABS.DAT   MYSPACES.DAT   6  15  27
  511.  
  512.        says that tab stops are at positions 1, 6, 15, 27, 39, 51... etc.  The 
  513.        interval of 12 between 15 and 27 is propagated to subsequent tab stops.
  514.  
  515.        After creating MYSPACES.DAT as in the above examples, you could then
  516.        use RPSORT to sort it in the usual way.
  517.  
  518.        You can also use RPTAB for the reverse operation.  This means to 
  519.        replace spaces by tabs whenever possible.  The syntax is:
  520.  
  521.            RPTAB  /T input-filespec  output-filespec  [tabstop...]
  522.  
  523.        The syntax is identical except for the addition of the /T switch.  
  524.        If you have a text file with a lot of spaces, RPTAB can reduce its 
  525.        size while leaving it readable by many text processing utilities.
  526.  
  527.  
  528.  
  529.   October 10, 1991             RPSORT Examples                       Page   9
  530.  
  531.  
  532.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  533.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  534.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  535.  
  536.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  537.  
  538.  
  539.   RPSORT Examples Of Special Interest To Computer Programmers
  540.  
  541.  
  542.    30. The attribute C in a sort key definition says that the key is a C
  543.        language string.  This means that a binary zero, if present,
  544.        terminates the string.  Specify a key length equal to the maximum
  545.        length for the string.  For example, if you define "char mystr[7]" in
  546.        your C program then you should specify a key length of 7 to RPSORT.
  547.  
  548.        In this example, the first sort key is a C style string at column 1
  549.        whose maximum length is 7.  The second key is a C style string at
  550.        column 25 with maximum length 5.
  551.  
  552.            RPSORT  /F95  /+:7ACR  /+25:5C  CSTRING.DAT  SORTCSTR.DAT
  553.  
  554.  
  555.    31. RPSORT allows some of your sortkeys to be C style strings and some to
  556.        be regular character strings as in this example.
  557.  
  558.            RPSORT  /F80  /+13:12C  /+5:5  DATA.DAT  SORT.DAT
  559.  
  560.  
  561.    32. The attribute P in a sort key definition says that the key is a Turbo
  562.        Pascal string.  This means that the first byte of the key is a binary
  563.        integer representing the length of the actual string.
  564.  
  565.        You should specify a key length equal to one plus the maximum possible
  566.        length for the string.  For example, if you define "string[9] in your
  567.        Pascal program then you should specify a key length of 10 to RPSORT.
  568.        The one extra allows for the length byte.  Pascal strings are only
  569.        allowed as sort keys in fixed length records.
  570.  
  571.        In this example, the first sort key is a Pascal style string at column
  572.        3 whose maximum length is 9 (one less than the length of the key.  It
  573.        is to be sorted per the descending ASCII sequence.  The second key is
  574.        a Pascal style string at column 12 with a maximum length of 8.  It is
  575.        to be sorted per the case insensitive sequence.
  576.  
  577.            RPSORT  /F70  /+3:10APR  /+12:9P  PSTRING.DAT SORTPSTR.DAT
  578.  
  579.  
  580.    33. RPSORT allows some of your sortkeys be Pascal style strings and some
  581.        to be regular character strings as in this example.
  582.  
  583.            RPSORT  /F60  /+9:10  /+1:8P  PASCAL.DAT SORT.DAT
  584.  
  585.  
  586.  
  587.   October 10, 1991             RPSORT Examples                       Page  10
  588.  
  589.  
  590.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  591.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  592.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  593.  
  594.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  595.  
  596.  
  597.   RPSORT Examples Of Special Interest To Computer Programmers (continued)
  598.  
  599.  
  600.    34. The /C switch tells RPSORT that all your character string sort keys
  601.        are to be treated as C style strings.  If you specify /C, you can't
  602.        over-ride it for an individual sort key.  If you want some string keys
  603.        to be C style strings and some not, don't use /C.  Instead, specify C
  604.        in the appropriate sort key definitions.
  605.  
  606.            RPSORT  /F67  /C  /+3:9A  /+23:7  DATA.DAT  SORT.DAT
  607.  
  608.  
  609.    35. The /P switch tells RPSORT that all your character string sort keys
  610.        are to be treated as Pascal style strings.  If you specify /P, you
  611.        can't over-ride it for an individual sort key.  If you want some
  612.        string keys to be Pascal strings and some not, don't use /P but
  613.        instead specify P in the appropriate sort key definitions.
  614.  
  615.        Note that /C and /P are mutually exclusive.
  616.  
  617.            RPSORT  /F98  /P  /+23:11  /+12:67A  DATA.DAT  SORT.DAT
  618.  
  619.  
  620.    The remaining examples include sort keys which are binary numbers of some
  621.    type.  The table on page 12 lists the appropriate type and length
  622.    attributes for the binary number formats defined in several popular
  623.    compilers and interpreters.  Binary number sort keys are only allowed in
  624.    fixed length records.
  625.  
  626.  
  627.    36. The I attribute tells RPSORT that the first sort key, in this example,
  628.        is a signed binary integer.  RPSORT supports binary integers of any
  629.        length.  In this case the length of 8 would be appropriate for number
  630.        of the "comp" type in Turbo Pascal.
  631.  
  632.            RPSORT  /F112  /+12:8I  /+1:9P  INTEGER.DAT  SORTINT.DAT
  633.  
  634.  
  635.    37. This example produces the exact same result as the previous one.
  636.        Note that instead of using the P attribute in the second sort key
  637.        definition, I used the /P switch.  The important point is that while
  638.        the /P switch would apply to all character string keys it does not
  639.        apply to the first sort key because that is defined as a binary number
  640.        sort key.
  641.  
  642.            RPSORT  /F112  /P  /+12:8I  /+1:9  INTEGER.DAT  SORTINT.DAT
  643.  
  644.  
  645.  
  646.   October 10, 1991             RPSORT Examples                       Page  11
  647.  
  648.  
  649.   Usage:  RPSORT  [/Q]  [/Eerrfile]  [/]?  [inputfile[+inputfile]]
  650.                   [outputfile]  [/A]  [/B]  [/C]  [/D]  [/Fnnnn]  [/N]  [/P]
  651.                   [/R]  [/Td]  [/Z]  [sort key defin. . .]
  652.  
  653.   Sort key defin syntax:  /+ [col] [:len] [A] [C] [F] [I] [M] [P] [R] [T] [U]
  654.  
  655.  
  656.   RPSORT Examples Of Special Interest To Computer Programmers (continued)
  657.  
  658.  
  659.    38. The U attribute tells RPSORT that the second sort key is an unsigned
  660.        binary integer of length 2.  RPSORT supports binary integers of any
  661.        length.  In this case the length of 2 would be appropriate for an
  662.        "unsigned int" in Turbo C.
  663.  
  664.            RPSORT  /F97  /+2:11C  /+12:2U  UNSIGNED.DAT  SORT.DAT
  665.  
  666.  
  667.    39. The F attribute tells RPSORT that the first sort key, in this example,
  668.        is an 80x87 floating point number.  RPSORT supports three different
  669.        precisions for these numbers.  The table below gives the lengths for
  670.        each precision and the names assigned to them by Intel and by three
  671.        popular compilers.
  672.  
  673.           Length    Intel         QuickBasic    Turbo Pascal    Turbo C
  674.           ------    ----------    ----------    ------------    -------
  675.              4      short real    single        single          float
  676.              8      long  real    double        double          double
  677.             10      temp  real    N/A           extended        long double
  678.  
  679.        In this example the length of 8 would be appropriate for a sort key of
  680.        type double in any of the three compilers listed above.
  681.  
  682.            RPSORT  /F125  /+:8F  /+13:4  FLOAT.DAT  SORT.DAT
  683.  
  684.  
  685.    40. The M attribute tells RPSORT that the second sort key is a floating
  686.        point number of the type supported by BASICA, GWBASIC and older
  687.        versions of QuickBASIC (v3.0 and earlier).  RPSORT supports the 4 byte
  688.        single precision and the 8 byte double precision formats.
  689.  
  690.            RPSORT  /F92  /+13:8C  /+2:4M  BASICA.DAT  SORT.DAT
  691.  
  692.    41. The T attribute tells RPSORT that the first sort key is a Turbo Pascal
  693.        type "real" number.  This was the only floating point type in Turbo
  694.        Pascal versions 1.0 through 3.0.  It is still supported in version 6.0
  695.        but Turbo Pascal has now added the 80x87 floating point types (see
  696.        example 39 above and the table on page 12).
  697.  
  698.        I did not specify any length attribute because the length for this
  699.        type is always 6.  If you do specify a length, it must be 6.
  700.  
  701.            RPSORT  /F87  /+10T  /+3:7P  PASCAL.DAT  SORT.DAT
  702.  
  703.  
  704.  
  705.   October 10, 1991             RPSORT Examples                       Page  12
  706.  
  707.  
  708.   The following table lists the type and length attributes for the binary
  709.   numeric types available in a few programming language compilers and
  710.   interpreters.
  711.  
  712.  
  713.   Compiler Or Interpreter       Number Type  Type Attribute  Length Attribute
  714.   -----------------------       -----------  --------------  ----------------
  715.   Microsoft QuickBASIC          Integer             I                2
  716.    v4.0 and later &             Long                I                4
  717.   Microsoft QBASIC              Single              F                4
  718.                                 Double              F                8
  719.  
  720.   Microsoft QuickBASIC          Integer             I                2
  721.    v3.0, 8087                   Single              F                4
  722.                                 Double              F                8
  723.  
  724.   IBM BASICA &                  Integer             I                2
  725.   Microsoft GWBASIC &           Single              M                4
  726.   Microsoft QuickBASIC          Double              M                8
  727.    v1.0, v2.0 and v3.0 non-8087
  728.  
  729.   Turbo Pascal                  Shortint            I                1
  730.    v4.0 and later               Integer             I                2
  731.                                 Longint             I                4
  732.                                 Byte                U                1
  733.                                 Word                U                2
  734.                                 Real                T                6
  735.                                 Single              F                4
  736.                                 Double              F                8
  737.                                 Extended            F               10
  738.                                 Comp                I                8
  739.  
  740.   Turbo Pascal                  Integer             I                2
  741.    v3.0 8087                    Byte                U                1
  742.                                 Real                F                8
  743.  
  744.   Turbo Pascal                  Integer             I                2
  745.    v1.0, v2.0 and v3.0 non-8087 Byte                U                1
  746.                                 Real                T                6
  747.  
  748.   Borland/Turbo C               signed char         I                1
  749.                                 unsigned int        U                2
  750.                                 short int           I                2
  751.                                 int                 I                2
  752.                                 unsigned long       U                4
  753.                                 long                I                4
  754.                                 float               F                4
  755.                                 double              F                8
  756.                                 long double         F               10
  757.  
  758.  
  759.