Debian Codegraph @

reports/alive.ll

raw
1 /*
2 * @progname alive.ll
3 * @version 6
4 * @author Jim Eggert
5 * @category
6 * @output Text
7 * @description
8
9 This report program is for finding people living in a given year.
10 This finds who in the database, or among ancestors or descendants of
11 an individual, was likely alive in a certain year. Good for looking at
12 population snapshots like censuses, tax rolls, etc.
13
14 Version 1, 13 July 1994, by Jim Eggert, [email protected]
15 Version 2, 14 July 1994, by Jim Eggert, fixed bug in estimate_byear
16 Version 3, 22 July 1994, by Jim Eggert, fixed another bug in estimate_byear,
17 minor format improvement
18 Version 4, 15 March 1995, by Frank Flaesland, added support for listing places
19 Version 5, 17 March 1995, J.F.Chandler, modified to prune place list
20 Version 6, 27 Aug 1997, by Jim Eggert, fixed bug in print_header()
21
22 ** SourceForge Versions:
23 **
24 ** $Log: alive.ll,v $
25 ** Revision 1.6 2004/07/19 05:54:54 dr_doom
26 ** Merge Vincent Broman Changes to reports
27 **
28 ** Revision 1.4 2000/11/29 12:17:11 nozell
29 ** Fix typo.
30 **
31 ** Revision 1.3 2000/11/28 21:39:45 nozell
32 ** Add keyword tags to all reports
33 ** Extend the report script menu to display script output format
34 **
35 ** Revision 1.2 2000/11/11 17:48:13 pere
36 ** Get this report working. Fixed type problems and handle empty
37 ** place tags without crashing. Add meta information.
38 **
39 **
40 */
41
42 global(byear)
43 global(byear_delta)
44 global(byear_est)
45 global(byear_est_delta)
46 global(dyear_est)
47 global(dyear_est_delta)
48 global(old_age)
49 global(maximum_age)
50 global(mother_age)
51 global(father_age)
52 global(years_between_kids)
53 global(first_person)
54 global(who)
55 global(of)
56 global(places)
57
58 proc main() {
59 /* Assumptions for guessing year of birth */
60 set(old_age,60) /* assumed age at death */
61 set(maximum_age,120)/* maximum possible age */
62 set(mother_age,23) /* assumed age of first motherhood */
63 set(father_age,25) /* assumed age of first fatherhood */
64 set(years_between_kids,2) /* assumed years between children */
65
66 indiset(people)
67 set(first_person,1)
68
69 getintmsg(who,
70 "Find live persons (0=all, 1=desc, 2=desc and spouses, 3=anc) ")
71 if (who) { getindimsg(of,"of ") }
72 getintmsg(when,"alive in which year?")
73 set(places, 1)
74 getstrmsg(yesno,"List possible places? (y/n) ")
75 if (strlen(yesno)) {
76 if (strcmp(upper(trim(yesno,1)),"Y")) { set(places,0) }
77 }
78
79 if (eq(who,0)) {
80 forindi(person,pnum) {
81 call alive(person,when)
82 }
83 }
84 else {
85 addtoset(people,of,0)
86 if (or(eq(who,1),eq(who,2))) { set(people,descendentset(people)) }
87 elsif (eq(who,3)) { set(people,ancestorset(people)) }
88 addtoset(people,of,0)
89 if (eq(who,2)) { set(people,union(people,spouseset(people))) }
90 forindiset(people,person,pval,pnum) {
91 call alive(person,when)
92 }
93 }
94 }
95
96 proc print_person(person) {
97 key(person)
98 col(9) fullname(person,0,1,50)
99 col(61) "("
100 if (gt(byear_est_delta,1)) { "c" }
101 d(byear_est)
102 "-"
103 if (gt(dyear_est_delta,1)) { "c" }
104 d(dyear_est)
105 ")\n"
106 if (eq(places,1)) { call print_places(person) }
107 }
108
109 proc print_places(person) {
110 list(place_names)
111 table(places_seen)
112 traverse (inode(person), node, level) {
113 if (eq(strcmp(tag(node), "PLAC"), 0)) {
114 set(p, value(node))
115 if(lookup(places_seen,p)) { continue() }
116 insert(places_seen, p, 1)
117 extractplaces(node, place_names, num_places)
118 if (gt (num_places,0)) {
119 " " pop(place_names)
120 while (p, pop(place_names)) { ", " p }
121 "\n"
122 }
123 }
124 }
125 }
126
127 proc print_header(year) {
128 set(current_year,strtoint(year(gettoday())))
129 if (ge(year,current_year)) { set(future,1) } else { set(future,0) }
130
131 "________________________________________________________________________\n"
132 "List of "
133 if (eq(who,0)) { "all persons" }
134 elsif (or(eq(who,1),eq(who,2))) { "descendants" }
135 elsif (eq(who,3)) { "ancestors" }
136 if (ge(who,1)) { " of\n" key(of) " " fullname(of,0,1,70) "\n" }
137 else { " " }
138 if (eq(who,2)) { "and their spouses" }
139 if (future) { "who are likely to be" }
140 else { "who are likely to have been" }
141 " alive in " d(year) "\n\n"
142 "________________________________________________________________________\n"
143 "Key" col(9) "Name" col(61) "(born-died)\n"
144 "________________________________________________________________________\n"
145 }
146
147 proc alive(person,year) {
148 set(dyear_est,0)
149 call estimate_byear(person)
150 if (byear_est) {
151 if (and(le(byear_est,add(year,byear_est_delta)),
152 gt(byear_est,sub(year,maximum_age)))) {
153 set(dyear_est,atoi(year(death(person))))
154 if (not(dyear_est)) {
155 set(dyear_est,atoi(year(burial(person))))
156 }
157 else { set(dyear_est_delta,0) }
158 if (not(dyear_est)) {
159 set(dyear_est,add(byear_est,old_age))
160 set(dyear_est_delta,20)
161 }
162 else { set(dyear_est_delta,1) }
163 if (ge(dyear_est,year)) {
164 if (first_person) {
165 call print_header(year)
166 set(first_person,0)
167 }
168 call print_person(person)
169 }
170 }
171 }
172 }
173
174 proc estimate_byear(person) {
175 set(byear_est,0)
176 set(byear_est_delta,neg(1))
177 call get_byear(person)
178 if (byear) {
179 set(byear_est,byear)
180 set(byear_est_delta,byear_delta)
181 }
182 else { /* estimate from siblings */
183 set(older,person)
184 set(younger,person)
185 set(yeardiff,0)
186 set(border,0)
187 set(this_uncertainty,1)
188 while (and(not(byear_est),or(older,younger))) {
189 set(older,prevsib(older))
190 set(younger,nextsib(younger))
191 set(yeardiff,add(yeardiff,years_between_kids))
192 set(this_uncertainty,add(this_uncertainty,1))
193 if (older) {
194 set(border,add(border,1))
195 call get_byear(older)
196 if (byear) {
197 set(byear_est,add(byear,yeardiff))
198 set(byear_est_delta,this_uncertainty)
199 }
200 }
201 if (and(not(byear_est),younger)) {
202 call get_byear(younger)
203 if (byear) {
204 set(byear_est,sub(byear,yeardiff))
205 set(byear_est_delta,this_uncertainty)
206 }
207 }
208 }
209 }
210 if (not(byear_est)) { /* estimate from parents' marriage */
211 if (m,marriage(parents(person))) { extractdate(m,bd,bm,my) }
212 if (my) {
213 set(byear_est,add(add(my,mul(years_between_kids,border)),1))
214 set(byear_est_delta,add(border,1))
215 }
216 }
217 if (not(byear_est)) { /* estimate from first marriage */
218 families(person,fam,spouse,fnum) {
219 if (eq(fnum,1)) {
220 if (m,marriage(fam)) { extractdate(m,bd,bm,my) }
221 if (my) {
222 if (female(person)) { set(byear_est,sub(my,mother_age)) }
223 else { set(byear_est,sub(my,father_age)) }
224 set(byear_est_delta,5)
225 }
226 else {
227 children(fam,child,cnum) {
228 if (not(byear_est)) {
229 call get_byear(child)
230 if (byear) {
231 if (female(person)) {
232 set(byear_est,sub(sub(byear,
233 mul(sub(cnum,1),years_between_kids)),
234 mother_age))
235 }
236 else {
237 set(byear_est,sub(sub(byear,
238 mul(sub(cnum,1),years_between_kids)),
239 father_age))
240 }
241 set(byear_est_delta,add(5,cnum))
242 }
243 }
244 }
245 }
246 }
247 }
248 }
249 if (not(byear_est)) { /* estimate from parents' birthyear */
250 call get_byear(mother(person))
251 if (byear) {
252 set(byear_est,add(byear,mother_age))
253 }
254 else {
255 call get_byear(father(person))
256 if (byear) {
257 set(byear_est,add(byear,father_age))
258 }
259 }
260 if (byear) {
261 set(byear_est_delta,5)
262 set(older,person)
263 while(older,prevsib(older)) {
264 set(byear_est,add(byear_est,years_between_kids))
265 set(byear_est_delta,add(byear_est_delta,1))
266 }
267 }
268 }
269 }
270
271 proc get_byear(person) {
272 set(byear,0)
273 if (person) {
274 if (b,birth(person)) { extractdate(b,day,month,byear) }
275 if (byear) {
276 set(byear_delta,0)
277 set(dstring,trim(date(b),3))
278 if (not(strcmp(dstring,"BEF"))) { set(byear_delta,3) }
279 elsif (not(strcmp(dstring,"AFT"))) { set(byear_delta,3) }
280 elsif (not(strcmp(dstring,"ABT"))) { set(byear_delta,2) }
281 }
282 else {
283 if (b,baptism(person)) { extractdate(b,day,month,byear) }
284 if (byear) {
285 set(byear_delta,1)
286 set(dstring,trim(date(b),3))
287 if (not(strcmp(dstring,"BEF"))) { set(byear_delta,3) }
288 elsif (not(strcmp(dstring,"AFT"))) { set(byear_delta,3) }
289 elsif (not(strcmp(dstring,"ABT"))) { set(byear_delta,2) }
290 }
291 }
292 }
293 }