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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
############################################################################
#
# File: adlcheck.icn
#
# Subject: Program to check for bad address list data
#
# Author: Ralph E. Griswold
#
# Date: November 19, 1997
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This program checks address lists for correctness.
#
# There are five options:
#
# -s Check state (U.S. labels only)
# -z Check ZIP code (U.S. labels only)
# -c Check country name (a very heuristic check)
# -a Check all of the above
# -d Report addresses that exceed "standard dimensions" for labels:
# 40 character line length, 8 lines per entry
#
############################################################################
#
# See also: address.doc, adlcount.icn, adlfiltr.icn, adllist.icn,
# adlsort,icn, labels.icn
#
# Links: adlutils, options
#
############################################################################
link adlutils, options
procedure main(args)
local opts, choice, item, badchar, print, states, i, line, dim, add
states := set(["AK", "AL", "AR", "AS", "AZ", "CA", "CO", "CT", "DC",
"DE", "FL", "FM", "GA", "GU", "HI", "IA", "ID", "IL", "IN", "KS",
"KY", "LA", "MA", "MD", "ME", "MH", "MI", "MN", "MO", "MP", "MS",
"MT", "NC", "ND", "NE", "NH", "NJ", "NM", "NV", "NY", "OH", "OK",
"ON", "OR", "PA", "PR", "PW", "RI", "SC", "SD", "TN", "TX", "UT",
"VA", "VT", "WA", "WI", "WV", "WY"])
print := ""
badchar := ~&ucase -- ' .' # very heuristic country name check
opts := options(args,"acszd")
if \opts["a"] then { # if -a, do all
opts["a"] := &null
every opts[!"csz"] := 1
}
if \opts["d"] then dim := write(1) # dimension check
while add := nextadd() do {
add.text ? {
i := 0
while line := tab(upto('\n') | 0) do {
i +:= 1
if *line > 40 then print ||:= "o"
move(1) | break
}
if i > 8 then print ||:= "o"
}
every \opts[choice := !"csz"] do
case choice of {
"c": { # check country name
get_country(add) ? {
if upto(badchar) then {
print ||:= choice
}
}
}
"s": { # check state
if not member(states,get_state(add)) then {
print ||:= choice
}
}
"z": {
if get_zipcode(add) == "9999999999" then {
print ||:= choice
}
}
}
if *print > 0 then {
every choice := !print do
write("*** ",case choice of {
"c": "bad country name"
"s": "bad state abbreviation"
"z": "bad ZIP code"
"o": \dim & "size exceeds label dimensions"
})
write()
writeadd(add)
print := ""
}
}
end
|