File: BW_descendants.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (472 lines) | stat: -rw-r--r-- 15,653 bytes parent folder | download | duplicates (5)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/*
 * @progname    BW_descendants.ll
 * @version     1.00
 * @author      Birger Wathne
 * @category
 * @output      Text
 * @description
 *              List successors with notes

BW_descendants - a LifeLines report by Birger Wathne (Birger.Wathne@sdata.no)

Version 1.00
This program partially based on code by Brad Frecker and Dick Knowles.
Suggestions and comments welcome.


Output sample at bottom of this source file.

This report generates a list of successors of the given person. For each
successor and its spouse(s), all level 1 notes are listed.

The report asks for some parameters:
- Number of generations to include (0 gives all)
- Amount of output for spouse's other families
        0 - Only list the main person's marriages. Don't even mention
            the fact that the spouse(s) have had other relationships.
        1 - Print a one-line summary for each of the spouse's other
            relationships (number of children, spouses name, etc)
        2 - Print the one-liner from option 1, plus a full listing of
            all stepchildren (not recursive)
- Output type
        0 - Text. Plain ascii output (like the sample)
        1 - roff. Not finished, as I don't have an 8-bit clean roff.
            If someone wants this, please finish it, and send me the code.
        2 - HTML. This output uses <TABLE> tags, so you need HTML 3.0 support.
            Uses bold fonts, etc. Nice....
- Language for generated text. The header, and all those small words
  used in the output can be generated in the language you have your
  data. Makes it look more natural. If you add new languages, please tell me.
*/

global(strings)
global(outputtype)
global(true)
global(false)

func init_strings(language) {
        if ( eq( language, 0)) {
                insert(strings, "Header", "Successors of")
                insert(strings, "Headerdate", "Date")
                insert(strings, "Born", "Born")
                insert(strings, "Dead", "Dead")
                insert(strings, "Married", "Married")
                insert(strings, "Relationship", "Relationship")
                insert(strings, "with", "with")
                insert(strings, "unknownspouse", "unknown spouse")
                insert(strings, "descendants", "descendants")
                insert(strings, "generations", "generations")
                insert(strings, "children", "children")
                insert(strings, "had", "had")
                insert(strings, "all", "all")
                insert(strings, "Notesfor", "Notes for")

                return(0)
        }

        if ( eq( language, 1)) {
                insert(strings, "Header", "Etterkommere etter")
                insert(strings, "Headerdate", "Dato")
                insert(strings, "Born", "F�dt")
                insert(strings, "Dead", "D�d")
                insert(strings, "Married", "Gift")
                insert(strings, "Relationship", "Forhold")
                insert(strings, "with", "med")
                insert(strings, "unknownspouse", "ukjent ektefelle")
                insert(strings, "descendants", "etterkommere")
                insert(strings, "generations", "generasjoner")
                insert(strings, "children", "barn")
                insert(strings, "had", "hadde")
                insert(strings, "all", "alle")
                insert(strings, "Notesfor", "Notater for")

                return(0)
        }

        return(1)
}


proc main () {
        table(strings)

        set(true, 1)
        set(false, 0)

        dayformat(0)
        monthformat(4)
        dateformat(0)

        getindi(indi)

        getintmsg (generation_count, "How many generations (0 for all)?")
        if ( lt( generation_count, 0)) {
                print("Illegal number of generations")
                return()
        }

        getintmsg (
                spousefamilies,
                "How much output for spouse's other families (0=none, 1=summary, 2=list children)?"
        )
        if ( or( lt( spousefamilies, 0), gt( spousefamilies, 2))) {
                print("Illegal answer")
                return()
        }

        getintmsg(outputtype, "Output type (0=TEXT, 1=ROFF, 2=HTML)?")
        if ( or( lt( outputtype, 0), gt( outputtype, 2))) {
                print("Illegal output type")
                return()
        }


        getintmsg(
                language,
                "Language for generated text (0=English, 1=Norwegian)?"
        )
        if ( ne( init_strings(language), 0)) {
                print("Couldn't initialize string table to selected language")
                return()
        }

        output_init()
        /* Headers */
        if ( eq( generation_count, 0)) {
                output_header1 (
                        concat(
                                lookup( strings, "Header")," ",
                                name(indi), " ",
                                lookup( strings, "with"), " ",
                                lookup( strings, "all"), " ",
                                lookup( strings, "descendants")
                        )
                )
        } else {
                if ( eq( generation_count, 1)) {
                        output_header1 (
                                concat(
                                        lookup( strings, "Header"), " ",
                                        name(indi), " "
                                )
                        )
                } else {
                        output_header1 (
                                concat(
                                        lookup( strings, "Header"), " ",
                                        name(indi), " ",
                                        lookup( strings, "with"), " ",
                                        d(sub(generation_count,1)), " ",
                                        lookup( strings, "generations"), " ",
                                        lookup( strings, "descendants")
                                )
                        )
                }
        }
        nl() nl()

        output_header2(
                concat(
                        lookup( strings, "Headerdate"), ": ",
                        stddate(gettoday())
                )
        )
        nl() nl()

        call descendants(indi, "1", generation_count, spousefamilies)
        output_terminate()
}



proc descendants (indi, number, generation_count, spousefamilies) {
        output_startpara()
        number output_linebreak()
        call print_person(indi, 1)

        call write_notes(indi)

        set(childnumber, 0)

        families(indi, family, spouse, i) {
                if(e, marriage(family)) {
                        lookup( strings, "Married") " " stddate(e)
                } else {
                        lookup( strings, "Relationship")
                }

                if ( ne( spouse, null)) {
                        " " lookup( strings, "with") " "
                        call print_person(spouse, 1)
                } else {
                        " " lookup( strings, "with") " "
                        lookup( strings, "unknownspouse")
                }

                if ( ne(spousefamilies, 0)) {
                        families(spouse, spfamily, spspouse, j) {
                                if (ne(family, spfamily)) {
                                        name(spouse) " "
                                        lookup( strings, "had") " "
                                        d(nchildren(spfamily)) " "
                                        lookup( strings, "children")
                                        if ( ne( spspouse, null)) {
                                                " " lookup( strings, "with") " "
                                                call print_person(spspouse, 0)
                                        } else {
                                                " " lookup( strings, "with") " "
                                                lookup( strings, "unknownspouse")
                                        }
                                        if( eq(spousefamilies, 2)) {
                                                output_leftin()
                                                children(spfamily, child, k) {
                                                        "\t"
                                                        call print_person(child, 0)
                                                }
                                                output_leftout()
                                        }
                                }
                        }
                }

                call write_notes(spouse)

                output_leftin()
                children(family, child, j) {
                        "\t" number "." d(add(j, childnumber)) nl() "\t"
                        call print_person(child, 1)
                }
                output_leftout()
                set(childnumber, add(childnumber, j))
        }

        output_endpara()

        set(childnumber, 0)

        families(indi, family, spouse, i) {
                if (ne(1, generation_count)) {
                        if ( gt(generation_count, 1)) {
                                decr(generation_count)
                        }
                        children(family, child, j) {
                                call descendants (
                                        child,
                                        strconcat(
                                                number, ".",
                                                d(add(j, childnumber))
                                        ),
                                        generation_count, spousefamilies)
                        }
                        set(childnumber, add(childnumber, j))
                }
        }

}



proc write_notes(indi) {
        set(done_header, 0)
        fornodes(inode(indi), node) {
                if (eq(0,strcmp("FILE", tag(node)))) {
                        if ( eq(done_header, 0) ) {
                                lookup( strings, "Notesfor") " "
                                name(indi) ":" output_linebreak()
                                incr(done_header)
                        }
                        copyfile(value(node))
                } elsif (eq(0,strcmp("NOTE", tag(node)))) {
                        if ( eq(done_header, 0) ) {
                                lookup( strings, "Notesfor") " "
                                name(indi) ":" output_linebreak()
                                incr(done_header)
                        }
                        value(node)
                        fornodes(node, subnode) {
                                if (eq(0,strcmp("CONT", tag(subnode)))) {
                                        nl() value(subnode)
                                }
                        }
                        output_linebreak()
                }
        }
}


proc print_person (indi, bold) {
        if(bold) {
                output_bold( name(indi))
        } else {
                name(indi)
        }
        if (e, stddate(birth(indi))) {
                ", " lookup( strings, "Born") " " e
        }
        if(e, stddate(death(indi))) {
                ", " lookup( strings, "Dead") " " e
        }
        "." output_linebreak()
}


func output_header1 (string) {
        if ( eq( outputtype, 1)) {
                return(concat( ".(b C", nl(), ".ps 16", nl(), "\\fB",
                        split(string), "\\fP", nl(),
                        ".ps 8", nl(), ".)b", nl()))
        }
        if ( eq( outputtype, 2)) {
                return(concat( "<H1>", string, "</H1>"))
        }
        return(string)
}

func output_header2 (string) {
        if ( eq( outputtype, 1)) {
                return(concat( ".(b C", nl(), ".ps 12", nl(), "\\fB",
                        string, "\\fP", nl(),
                        ".ps 8", nl(), ".)b", nl()))
        }
        if ( eq( outputtype, 2)) {
                return(concat( "<H2>", string, "</H2>"))
        }
        return(string)
}


func output_init () {
        if ( eq( outputtype, 1)) {
                return(concat( ".po 0.8i", nl(), ".ll 6.8i", nl(),
                        ".pl +1.5i", nl(), ".nf", nl(), ".ps 8", nl()))
        }
        if ( eq( outputtype, 2)) {
                return(concat("<HTML><HEAD><TITLE>Descendant chart</TITLE></HEAD><BODY>", nl() ))
        }
}


func output_terminate () {
        if ( eq( outputtype, 2)) {
                return("</BODY></HTML>")
        }
}


func output_linebreak () {
        if ( eq( outputtype, 1)) {
                return(nl())
        }
        if ( eq( outputtype, 2)) {
                return("<BR>")
        }
        return(nl())
}


func output_startpara () {
        if ( eq( outputtype, 2)) {
                return("<P>")
        }
}


func output_endpara () {
        if ( eq( outputtype, 2)) {
                return("</P>")
        }
        return(concat( output_linebreak(), output_linebreak()))
}

func output_bold (string) {
        if ( eq( outputtype, 1)) {
                return(concat( "\\fB", string, "\\fP"))
        }
        if ( eq( outputtype, 2)) {
                return(concat( "<B>", string, "</B>"))
        }
        return(string)
}


func output_leftin () {
        if ( eq( outputtype, 2)) {
                return(concat( "<TABLE WIDTH=100%><TR><TD WIDTH=5%></TD><TD>"))
        }
}


func output_leftout () {
        if ( eq( outputtype, 2)) {
                return(concat( "</TD></TR></TABLE>"))
        }
}


func split(string) {
        set(i, 1)
        set(tmpstr, "")
        while( ne( i, strlen(string))) {
                if ( nestr( substring( string, i, i), " ")) {
                        set(tmpstr, concat(tmpstr, substring( string, i, i)))
                } else {
                        set(tmpstr, concat(tmpstr, "\\0"))
                }
                incr(i)
        }
        return (tmpstr)
}


/* Sample output:


Successors of N.N. Helgesdtr. �SE with 2 generations descendants

Date: 14 Jun 1995

1
N.N. Helgesdtr. �SE.
Relationship with Tjeran Hallvardson (Halldors.) VASSHUS, Born        1610.
Notes for Tjeran Hallvardson (Halldors.) VASSHUS:
Er nevnt som leilending i 1635 sammen med Helge �se som sannsynligvis var
hans svigerfar.
Tjeran og broren Rasmus stevnet stefaren Laurits Asserson for odelsgods i
Kluge, Gjesdal som deres mor eide.
        1.1
        Lars Tjeranson �SE, Born        1643, Dead  9 Jun 1702.
        1.2
        Marite Tjerandsdtr. �SE, Dead        1691.
        1.3
        Hallvard TJERANSON, Born        1651.
        1.4
        Helge TJERANSON, Born        1654.


1.1
Lars Tjeranson �SE, Born        1643, Dead  9 Jun 1702.
Notes for Lars Tjeranson �SE:
Gift I med Kirsti Olsdtr. Malmeim (f.1665 d.12.04.1695).
II med Johanna Gunnarsdtr. Sveinsvoll (d.1741).
Lars hadde v�rt soldat i 10 �r. 2 barn kjent.


1.2
Marite Tjerandsdtr. �SE, Dead        1691.
Relationship with Ola Olson KJOSAVIK, Born        1623, Dead  9     1702.
Ola Olson KJOSAVIK had 7 children with KariI Pedersdtr., Born 16     , Dead        1674.
Ola Olson KJOSAVIK had 1 children with KariII Torkellsdtr. ALSNES, Born        1661, Dead 30 Mar 1705.
Notes for Ola Olson KJOSAVIK:
7 barn av f�rste ekteskap, 3 av andre og 1 av tredje ekteskap.
        1.2.1
        Berit Olsdtr. KJOSAVIK, Born        1674, Dead        1746.
        1.2.2
        Kristoffer Olson KJOSAVIK, Born        1677.
        1.2.3
        Ola O. KJOSAVIK, Born        1681, Dead 23     1695.

.
.
.

*/