Debian Codegraph @

reports/find.ll

raw
1 /*
2 * @progname find.ll
3 * @version 2.1
4 * @author Prinke, Perry Rapp
5 * @category
6 * @output GUI
7 * @description Display menu of persons with TAG having matching VALUE
8
9 This utility finds all persons whose records contain a specified
10 TAG and VALUE and displays the resulting list as a menu.
11
12 find.ll - Rafal Prinke, [email protected], 7 OCT 1995
13
14 The options allow to:
15
16 - find all occurrences of a given TAG when no VALUE is given
17 - find all occurrences of a given VALUE when no TAG is given
18 - find all occurrences of a given VALUE under a given TAG when
19 both are given (the CONT|CONC|TYPE tags are also searched)
20
21 The displayed VALUE is a 25 characters long substring of the field
22 value starting from the first occurence of the input value.
23
24 The results are displayed in a menuchoice list.
25 The first choice is to print the remaining choices to a file.
26 */
27 option(explicit)
28
29 proc main()
30 {
31 list(mnu)
32
33 getstr(tg, "TAG (enter=ANY)")
34 set(tg, upper(tg))
35
36 getstr(vl, "VALUE (enter=ANY)")
37 set(vl, upper(vl))
38
39 while (1)
40 {
41 getstr(rtype, "Records to search (I, F, S, E, X, or <enter> for any)")
42 set(rtype, upper(rtype))
43 if (or(eq(rtype, ""), index("IFSEX", rtype, 1)))
44 {
45 break()
46 }
47 }
48
49 set(outputChoice, "Print to output file")
50 enqueue(mnu, outputChoice)
51
52 /* people */
53 if (or(eq(rtype, ""), eq(rtype, "I")))
54 {
55 forindi (rec, n)
56 {
57 call search(rec, tg, vl, mnu)
58 }
59 }
60 /* families */
61 if (or(eq(rtype, ""), eq(rtype, "F")))
62 {
63 forfam (rec, n)
64 {
65 call search(rec, tg, vl, mnu)
66 }
67 }
68 /* sources */
69 if (or(eq(rtype, ""), eq(rtype, "S")))
70 {
71 forsour (rec, n)
72 {
73 call search(rec, tg, vl, mnu)
74 }
75 }
76 /* events */
77 if (or(eq(rtype, ""), eq(rtype, "E")))
78 {
79 foreven (rec, n)
80 {
81 call search(rec, tg, vl, mnu)
82 }
83 }
84 /* others */
85 if (or(eq(rtype, ""), eq(rtype, "X")))
86 {
87 forothr (rec, n)
88 {
89 call search(rec, tg, vl, mnu)
90 }
91 }
92
93 if (eq(length(mnu), 1))
94 {
95 print("No matches found")
96 }
97 else
98 {
99 set(chc, menuchoose(mnu, "Use record keys as below to browse to desired record"))
100 if (eq(chc, 1))
101 {
102 "Search for tag <" tg "> and value <" vl ">"
103 if (eq(rtype, "")) { " in all records" }
104 else { " in " rtype " records" }
105 " yielded " d(sub(length(mnu), 1)) " hits:\n"
106 forlist(mnu,s,c) {
107 if (ne(s, outputChoice))
108 {
109 s nl()
110 }
111 }
112 }
113 }
114 }
115
116 /*
117 Search rec (an INDI or FAM or ...)
118 for occurrences of tag tg with value vl
119 (Either may be empty as wildcards)
120 */
121 proc search(rec, tg, vl, mnu)
122 {
123 set(rnod, root(rec))
124 set(nodtyp, tag(rnod))
125 traverse (rnod, n, x)
126 {
127 set(xtag, upper(tag(n)))
128 set(xval, upper(value(n)))
129 if (eq(strlen(vl), 0))
130 {
131 set(ofst, 1)
132 }
133 else
134 {
135 set(ofst, index(xval, vl, 1))
136 }
137 if (or(or(and(eqstr(tg, xtag), or(index(xval, vl, 1),
138 eq(strlen(vl), 0))), and(eq(strlen(tg), 0), index(xval, vl, 1))),
139 and(index("CONTYPECONC", xtag, 1), index(xval, vl, 1))))
140 {
141 set(z, substring(value(n), ofst, strlen(xval)))
142 if (gt(strlen(z), 25))
143 {
144 set(z, substring(z, 1, 25))
145 }
146 set(result, concat(rjustify(key(rec), 6), " - "))
147 if (eq(nodtyp, "INDI"))
148 {
149 set(result, concat(result,
150 rjustify(fullname(rec, 1, 1, 18), 18)))
151 }
152 set(result, concat(result,
153 " - ", tag(parent(n)), ":", d(x), "_", tag(n), ":", z))
154 enqueue(mnu, result)
155 }
156 } /* traverse */
157 }