home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / p / sortv15.lbr / SORTDOC.TZT / SORTDOC.TXT
Encoding:
Text File  |  1993-10-25  |  6.5 KB  |  169 lines

  1.  
  2.                       HOW TO USE SORT, vers. 1.5
  3.  
  4. calling syntax:     SORT15 infile [outfile] [@<skip string>]
  5.  
  6. The characters to skip begin immediately after the "at" symbol, "@".
  7. SORT expects that the file to be sorted must be terminated by with a 
  8. CR/LF combination for every line.  If a "skip string" is used, the 
  9. characters which are to be skipped before performing the sort MUST be 
  10. present in every line.
  11.  
  12.  
  13. NOTES:
  14.  
  15. 1.  Characters in skip string need not be adjacent.
  16. 2.  If a tab character (^I) is to be included as a skip character, an 
  17.      output file MUST be specified, or use " . " as output name.
  18. 3.  Wildcard is "?".  Ex: SORT file @/??   sorts on 3d char after the 
  19.      slash.  Unfortunately, SORT15 cannot sort on question marks.  If a 
  20.      question mark is to be included in the skip string, use SORT 
  21.      version 14.
  22. 4.  The entire file to be sorted must fit into memory.  If the file is 
  23.      larger than available memory, the program will abort.
  24.  
  25.      Please note that in each of the examples which follow, I have 
  26. included an output file.  You will find this a good practice, as your 
  27. sort may not always turn out as you expect.  However, it is not 
  28. necessary to specify an output filename.  If you omit the output 
  29. filename, SORT will overwrite the original file.
  30.  
  31.  
  32.                             SAMPLES OF USE
  33.  
  34.  
  35. Data file looks like this:
  36.  
  37. Tom Jones,123 Main St.,Chicago,IL,60640
  38. Bob Jones,432 Prairie,Detroit, MI,99870
  39. Joe Smith,Box 15,Palmyra,NY,11265
  40. John Doe,The Morgue,New York,NY,11234
  41. The President,,Washington,DC,20202
  42. etc. . . .
  43.  
  44.  
  45. Example 1 --  ZIP CODE ORDER
  46.  
  47.      You want to rearrange these names into zip code order, then use
  48. MailMerge to create mailing labels for printing.  Since commas are the
  49. "delimiter" used in the datafile above, the zip code appears after the
  50. last comma (i.e., the 4th comma) in every case above.  This is a case
  51. when the characters used in the skip string need not be adjacent to
  52. each other.
  53.  
  54.      To sort these names in zip code order, simply type
  55.  
  56. SORT datafile.dat ziporder.dat @,,,,<return>
  57.  
  58.      Be sure not to include even a single space after the 4th comma, as
  59. SORT will include the space as a character in its skip string.  Since
  60. there are no spaces after the 4th comma on each line, no sort will be
  61. performed.
  62.  
  63.      If you have EMBEDDED commas in any field, the lines containing 
  64. these will be out of order.  Names added in DataStar, for example, may 
  65. contain embedded commas.  They look like this:
  66.  
  67.      John Taylor,"100 Park Ave., Apt. 3",Wooster,OH,47098
  68.      "Mike Michaels, Esq.","Heritage Plaza, 111 Ash Lane",Chicago...
  69.  
  70.      DataStar handles embedded commas by putting quotation marks around
  71. them.  This way, they are not confused for field delimiters.
  72. Unfortunately, they cannot be handled easily by SORT15.  If I had a
  73. file which needed to be sorted, however, I would do the sort and ignore
  74. the embedded commas.  Then, I would open up VDE and use ^QF to locate
  75. any lines with quotation marks.  Then I'd block the entire line (^KB,
  76. ^KK) and move it to its proper place.  A slower process, but necessary.
  77.  
  78.  
  79. Example 2 --  FIRST NAME ORDER
  80.  
  81.      You can sort the same datafile into alphabetical order, according
  82. to first name, simply by typing
  83.  
  84.      SORT filename.typ outfile.typ<return>
  85.  
  86.      All the names will be sorted according to first name and last
  87. name.  Remember that according to ASCII convention, all capital letters
  88. come before any small letters.  So you may come up with a sequence like
  89. this, which is strictly permissible in ASCII alphabetizing standards:
  90.      James Underwood
  91.      James Vanderbilt
  92.      James Williams
  93.      James van Gorden
  94.  
  95.  
  96. Example 3 --  LAST NAME ORDER
  97.  
  98.      The same datafile, now sorted alphabetically by first name, can be 
  99. sorted alphabetically by LAST name, even though there is not a comma 
  100. between the first and last names.  There IS a character which 
  101. distinguishes when the last name begins: the space.  The datafile can 
  102. be sorted by last name by typing
  103.  
  104.      SORT datafile outfile @<space><return>
  105.  
  106.      Note that you do not literally type 8 characters - "<space>" - but
  107. instead simply tap the spacebar once after typing "@", and then hit the
  108. return key.
  109.  
  110.      A potential problem may arise if you have included titles in your
  111. datafile (e.g., Dr., Mrs., Prof., Rev., etc.).  Since a space normally
  112. follows the title and the first name, any lines with titles will be out
  113. of order.
  114.  
  115.      You could escape this problem if your datafile was written like this:
  116.  
  117.           title,firstname lastname,address,city,st
  118.           Mr.,John Adams,PO Box 450,Grand Junction,CO
  119.           Prof.,Edward Hills,Harvard Univ.,Cambridge,MA
  120.           ,Molly McGuire,102 Fairhaven Dr.,Altadena,CA
  121.           ,Joe Nobody,PO Box 1402,Flushing,NY
  122.  
  123.      In such cases, to sort on last name, invoke the program like this:
  124.  
  125.      SORT infile outfile @,<space><return>
  126.  
  127.  
  128. Example 4 --  USING THE WILDCARD
  129.  
  130.      The wildcard symbol for the SORT string is the question mark.
  131. Thus, suppose you have a file where the first line begins with
  132. filenames which lack a period between the filename and filetype, like
  133. this:
  134.  
  135.      SETPRINTASM
  136.      VINST263CZM
  137.      VDE263  COM
  138.      WSMSGS  OVR
  139.      ZCPR    HLP
  140.  
  141.      If you want to the file sorted based on filetype, disregarding the 
  142. first 8 characters of the filename, you would invoke SORT as follows:
  143.  
  144.      SORT infile outfile @????????<return>
  145.  
  146.      Before going on to the next example, I'll just remind you that you 
  147. can use a TAB character (^I) in the skip string.
  148.  
  149.      Suppose you have a database program which accepts input for 
  150. telephone numbers, but doesn't add a hyphen between the area code and 
  151. the number.  For some reason, you want the list sorted according to 
  152. phone number, regardless of area code.  In this case, your skip string 
  153. would consist of the necessary delimiters, and then the question marks.
  154.  
  155.      FILE:  firstname,lastname,address,city,state,zip,phone
  156.             John,Jones,R.R. 4,Hampton,IA,99046,3097974312
  157.             Brad,Tacks,100 E. Ave.,Wiley,OK,69987,9873421048
  158.  
  159.      The sort syntax would be invoked like this:
  160.  
  161.      SORT infile outfile @,,,,,,???<return>
  162.  
  163.      In the example above, Brad Tacks, phone 342-1048, would be listed 
  164. before John Jones, 797-4312.
  165.  
  166.      Hope this gives you some good ideas on how to use SORT15!
  167.  
  168.                                --- suggestions by Eric Pement 02/14/88
  169.