summaryrefslogtreecommitdiff
path: root/ipl/progs/adllist.icn
blob: 9906a91358019e8fc8e484cf5db7074458c8e885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
############################################################################
#
#	File:     adllist.icn
#
#	Subject:  Program to list address list fields
#
#	Author:   Ralph E. Griswold
#
#	Date:     November 19, 1997
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#    This program lists entries in address lists. The options are:
#
#	-c	by country
#	-n	by name
#	-C	by city (U.S. only)
#	-s	by state (U.S. only)
#	-z	by ZIP code (U.S. only)
#
# 	The default is -n.  If more than one option is specified, the
#	order of dominance is -n -z -s -c -C.
#
############################################################################
#
#  See also: address.doc, adlcheck.icn, adlcount.icn, adlfiltr.icn, 
#     adlsort,icn, labels.icn
#
#  Links: adlutils, options
#
############################################################################

link adlutils, options

procedure main(args)
   local item, item_lists, opts, list_method, get_item, add

   item_lists := table()

   list_method := "n"			# The default is sorting by name.
   get_item := get_lastname

   opts := options(args,"cnszC")

   if \opts["C"] then {			# If more than one given, last applies.
      list_method := "C"
      get_item := get_city
      }
   if \opts["c"] then {			# If more than one given, last applies.
      list_method := "c"
      get_item := get_country
      }
   if \opts["s"] then {
      list_method := "s"
      get_item := get_state
      }
   if \opts["z"] then {
      list_method := "z"
      get_item := get_zipcode
      }
   if \opts["n"] then {
      list_method := "n"
      get_item := get_lastname
      }

   case list_method of {
      "s" | "z" | "C": while add := nextadd() do
         write(get_item(add))
      "c" : while add := nextadd() do
         write(format_country(get_item(add)))
      "n" : while add := nextadd() do
         write(get_namepfx(add)," ",get_item(add))
      }
       
end