
 SortAddr V2 - An address book sort utility for OzCIS V2

 1) History (and Excuses):
  The problem with sorting OzCIS address books is that the name field is
  free-form (the user can enter whatever he likes). This means that, for
  example:

          Acme Widgets Corp.
          A.N.Other [TeamOZ],
          Loudon Wainwright III,
          Mark Lathwell, and
          Michael A. Atherton

  are all acceptable input. This is fine as far as allowing users
  flexibility and freedom of expression goes, but it makes writing a
  useful sort routine difficult. For instance, in the above cases if the
  the "normal" approach of sorting on the last word of the field was used
  only Atherton and Lathwell would end up in a logical place (would you
  look for Acme Widgets to be "filed" under C, or Wainwright under III?).
  Anyhow, because of this when I wrote the first version of this utility
  I had it sort on the whole string (the examples above would end up in
  the order shown above). There was a work-around - the user had to edit
  the entries in the address book manually (to, for example, Other, A.N.
  [TeamOz] and Wainwright III, Loudon) but the problem then was that
  they appeared this way on the To: line of the message header.

  I got plenty of feedback from IBMCOM Sec. 12  (all of it positive,
  encouraging and very welcome) but most of it vaguely unhappy about
  this compromise. I also got a great idea (from Todd Fiske of TeamOZ)
  for overcoming this difficulty. This version incorporates his idea.

 2) Todd's Idea:
  ... was to use the third comment line of the address book record to
  pass the sort key. To sort on a particular part, say the third word, of
  the name, the number 3 is passed as the last word in the last comment
  line. For instance if you want Acme Widgets Corp. in the A's you would
  add 1 after whatever comment (if any) was in the last comment line, if
  however you want them under W (for Widgets) put the number 2 in the
  last comment line.  i.e. the sort is completely customisable - the choice
  is yours.

  My guess is that most name entries are "standard format", i.e. in a form
  such that sorting them on the last word of the name gives logical results,
  so I have made this the "normal" method - if the last comment field is
  empty or contains comments but no number) the utility sorts on the last
  field. This means that you only need to edit the comment field of a record
  if you feel that the normal method puts the entry in the wrong place for
  you, in most cases you probably won't need to do this. This should
  minimise set-up work editing the 3rd Comment line.















  Though appearing in the address book as "comments", these lines are entered
  in the Edit Address Book as "Notes", the number of the word to be sorted on
  is therefore added as shown below:

     +-[ ]-------------Edit Address Book------------------+
     |    Name    [                                     ] |
     |                                                    |
     |    Address [                                     ] |
     |                                                    |
     |   +-Notes ---------------------------------------+ |
     |   |                                              | |
     |   |                                              | |
     |   |<No. OF WORD TO SORT ON APPEARS HERE>         | |
     |   +----------------------------------------------+ |
     |                                                    |
     |   [F10-OK]           [F1-HELP]          [CANCEL]   |
     +----------------------------------------------------+

  If there is already text on comment line 3, the number goes at the end
  of that text, separated from it by a space, if there is no text the
  number can go at the start of the line. The other two lines may be empty
  -it makes no difference.
  The only essential is that the sort number is the LAST WORD OF THE LAST
  LINE in that Notes box.

  As an example of how this would works in practice, the following:

    NAME FIELD                           3RD COMMENT FIELD
    ----------                           -----------------
    Acme Widgets Corp.                   <the comments, if any> 1
    A.N.Other [TeamOz]                   <the comments, if any> 2
    Loudon Wainwright III                <the comments, if any> 2
    Mark Lathwell                        <comment only, if any>
    Michael A. Atherton                  <comment only, if any>


  would produce a sort into what I consider the sensible order, ie:

    Acme Widgets Corp.
    Michael A. Atherton
    Mark Lathwell
    A.N.Other [TeamOz]
    Loudon Wainwright III

  BUT (again) the order is completely customisable - if you think it
  sensible to have Acme Widgets under W (for Widgets) - because maybe you
  entries for several widget makers and want them all sorted together -
  or you are on first name terms with Loudon and want to look him up under L
  you only have to edit the 3rd comment line accordingly.

















  What actually happens when you force a custom sort like this is that (for
  the purposes of the sort only) a temporary string is created by "pasting"
  the chosen word to the front of the whole name field, so that e.g.if you
  choose to sort its entry on word 2 'Acme Widgets Corp.'  would be sorted
  as if it were 'Widgets Acme Widgets'!  Therefore the  records are sorted
  with the word you select as a primary field and then,  within that sort
  on the whole name. If you elected to sort these on  the word 'Widgets':

  Acme Widgets Corp.
  British Amalgamated Widgets
  Wally's Widgets Warehouse
  Widgets 'R' Us

  That would be the order they end up in but they would all be 'filed'
  under W (for widgets).

 3) Parameters:
  A single parameter gives the name (and/or path) of the address-book to be
  sorted. It is optional, if absent the OzCIS default address book,
  (addrbook.adr in the OzCis root directory) is assumed. If you keep your
  address book in another directory (because maybe you have a different
  address book in each of several host's directories) or you call it
  something else a parameter giving the name AND PATH of the address
  book file must be passed.

 4) How:
  The easiest way to use this is from the OzCIS externals menu, install
  it with "2nd Cmd processor?", and "Pause after execution?" checked. If
  you need parameters and its the same one every time it can be put on
  the command line with the program name

  eg.   SORTADDR  c:\ozcis2\host1

  otherwise, for multiple address books, and therefore different parameters
  the "Prompt for params?" should also be checked.

 5) Paranoia Department:
  I have tested the program fully and it works OK on my system, also the
  underlying version has been d/loaded (and presumably used) by many
  IBMCOM Sec 12 inmates without any reported problems BUT ...

  ... Obviously I can't foresee every configuration of equipment (or
  complexity of address book formats) on which this utility will be used
  so I cannot guarantee its infallibility (well, would you?).
  Therefore, JIC, the old, unsorted, address book is backed-up by the
  utility to a file with the same filename (but with the extension .BAK)
  so that, if something unexpected happens during sorting or file-saving
  all your lovingly entered address data will be retrievable.

 6) Thanks
  This little utility has developed from helpful and constructive
  comment from the IBMCOM Sec 12 gang for which I am grateful. Feedback
  via the forum is always welcome. Acknowledgement for the customisation
  idea leading to this update is due to Todd Fiske of TeamOz.
  I guess we ALL owe thanks to Steve Sneed for the excellent OzCIS and
  to TeamOz for their patience in gently guiding us all though it.

SortAddr is free to anyone who wants it. Hope you find it useful.

Richard Linter [70624,414] Somerset UK August 1993

Modifications:
 This small mod is to account for the fact that some address-book records 
 turn out to be delimited by ; (character #59) instead of  (character #179)
 which is normally as a delimitor. Now both are recognised as deleimitors.


