home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / adllist.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  80 lines

  1. ############################################################################
  2. #
  3. #    File:     adllist.icn
  4. #
  5. #    Subject:  Program to list address list fields
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     November 19, 1997
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #    This program lists entries in address lists. The options are:
  18. #
  19. #    -c    by country
  20. #    -n    by name
  21. #    -C    by city (U.S. only)
  22. #    -s    by state (U.S. only)
  23. #    -z    by ZIP code (U.S. only)
  24. #
  25. #     The default is -n.  If more than one option is specified, the
  26. #    order of dominance is -n -z -s -c -C.
  27. #
  28. ############################################################################
  29. #
  30. #  See also: address.doc, adlcheck.icn, adlcount.icn, adlfiltr.icn, 
  31. #     adlsort,icn, labels.icn
  32. #
  33. #  Links: adlutils, options
  34. #
  35. ############################################################################
  36.  
  37. link adlutils, options
  38.  
  39. procedure main(args)
  40.    local item, item_lists, opts, list_method, get_item, add
  41.  
  42.    item_lists := table()
  43.  
  44.    list_method := "n"            # The default is sorting by name.
  45.    get_item := get_lastname
  46.  
  47.    opts := options(args,"cnszC")
  48.  
  49.    if \opts["C"] then {            # If more than one given, last applies.
  50.       list_method := "C"
  51.       get_item := get_city
  52.       }
  53.    if \opts["c"] then {            # If more than one given, last applies.
  54.       list_method := "c"
  55.       get_item := get_country
  56.       }
  57.    if \opts["s"] then {
  58.       list_method := "s"
  59.       get_item := get_state
  60.       }
  61.    if \opts["z"] then {
  62.       list_method := "z"
  63.       get_item := get_zipcode
  64.       }
  65.    if \opts["n"] then {
  66.       list_method := "n"
  67.       get_item := get_lastname
  68.       }
  69.  
  70.    case list_method of {
  71.       "s" | "z" | "C": while add := nextadd() do
  72.          write(get_item(add))
  73.       "c" : while add := nextadd() do
  74.          write(format_country(get_item(add)))
  75.       "n" : while add := nextadd() do
  76.          write(get_namepfx(add)," ",get_item(add))
  77.       }
  78.        
  79. end
  80.