File: fami-grps.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 (409 lines) | stat: -rw-r--r-- 9,329 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
/*
 * @progname    fami-grps.ll
 * @version     1993-01-12
 * @author      Stephen Woodbridge (woodbri@swoodbridge.com)
 * @category
 * @output      Text, 80 cols
 * @description
 *
 *    Program walks thru one's families and dumps information
 *    about each family. It prunes the tree so an individual is
 *    only output once. The program lists all children of the
 *    families as it walks the tree. The "*" marker on a child
 *    signifies the line of descent/ascent.
 *
 *    Output assumes 132 characters wide and 80 lines per page.
 *
 *    Issues:
 *
 *      o only one child is marked in line of descent regardless
 *        of the actual number of children one may descend from
 *      o notes or family group records grater than LPP are NOT
 *        paginated correctly
 *      o program does not walk thru descendants yet
 *      o does not output baptism or burial records
 *      o does not list other spouses of HUSBAND or WIFE
 *
 *    Copyright 1993 Stephen Woodbridge
 */
global(UNKNOWN)
global(DONE)
global(ILIST)
global(NLIST)
global(RVAL)
global(nl)
global(ff)
global(PAGED)
global(PAGENO)
global(INDEXT)
global(INDEXS)
global(LPP)
global(LC)
global(NLF)
global(NLH)
global(NLW)
global(ONCE)

proc main()
{
    table(DONE)
    table(INDEXT)
    indiset(INDEXS)
    list(ILIST)
    list(NLIST)
    list(RVAL)
    set(nl, "\n")
    set(ff, "\f")
    set(PAGED, 1)
    set(PAGENO, 0)
    set(LPP, 80)
    set(LC, 0)
    set(NLF, 0)
    set(NLH, 0)
    set(NLW, 0)
    set(ONCE, 1)

    getindi(me)
    getintmsg(max, " Maximum Depth :")
    enqueue(ILIST, me)
    enqueue(NLIST, 1)
    set(i, 1)
    while (me, dequeue(ILIST))
    {
        set(depth, dequeue(NLIST))
        if (not(lookup(DONE, key(me))))
        {
            call do_me(me, depth, max)
        }
    }
    if (PAGED) { call print_index() }
}

proc do_me(me, depth, max)
{
    call fam_group(parents(me), 1, me, depth)
    if (le(add(depth, 1), max))
    {
        if (dad, father(me))
        {
            enqueue(ILIST, dad)
            enqueue(NLIST, add(depth, 1))
        }
        if (mom, mother(me))
        {
            enqueue(ILIST, mom)
            enqueue(NLIST, add(depth, 1))
        }
    }
}

proc fam_group(fam, notes, mchild, depth)
{
    if (fam)
    {
        call count_fgrp(fam, notes)
        call fg_hdr(fam, depth)
        call pparent(husband(fam), "HUSBAND:")
        col(6) "M: " long(marriage(fam)) nl
        call pparent(wife(fam), "   WIFE:")
        "CHILDREN:" nl
        children(fam, ch, nc)
        {
            insert(DONE, save(key(ch)), 1)
            call pchild(nc, ch, mchild)
        }
        if (notes)
        {
            call print_notes(husband(fam), "\nHusband: ", NLH)
            call print_notes(wife(fam), "\n   Wife: ", NLW)
        }
    }
    else
    {
        if (mchild)
        {
            call fg_hdr(fam, depth)
            call pparent(0, "HUSBAND:")
            col(6) "M:" nl
            call pparent(0, "   WIFE:")
            "CHILDREN:" nl
            insert(DONE, save(key(mchild)), 1)
            call pchild(1, mchild, mchild)
            if (notes)
            {
                call print_notes(mchild, "\n   Child: ", 0)
            }
        }
    }
}

proc addtoindex(me)
{
    addtoset(INDEXS, me, 1)
    if (l, lookup(INDEXT, key(me)))
    {
        enqueue(l, PAGENO)
        insert(INDEXT, save(key(me)), l)
    }
    else
    {
        list(l)
        enqueue(l, PAGENO)
        insert(INDEXT, save(key(me)), l)
    }
}

proc print_index()
{
    "\f------------------------ INDEX -----------------------------\n"
    nl
    namesort(INDEXS)
    forindiset(INDEXS, me, v, n)
    {
        call print_name(me, 1)
        pop(RVAL) col(50)
        set(first, 1)
        set(last, 0)
        forlist(lookup(INDEXT, key(me)), pg, n)
        {
            if (ne(last, pg))
            {
                if(first) { set(first, 0) }
                else { "," }
                d(pg)
                set(last, pg)
            }
        }
        nl
    }
}

proc fg_hdr(fam, depth)
{
    set(dash, " --------------------------- ")
    if (PAGED)
    {
        if (and(gt(NLF, LC), lt(NLF, LPP)))
        {
            set(PAGENO, add(PAGENO, 1))
            if (ONCE) { set(ONCE, 0) } else { ff }
            dash d(depth) dash col(80) "Page: " d(PAGENO) nl
            set(LC, sub(LPP, NLF))
        }
        else
        {
            dash d(depth) dash nl
            set(LC, sub(LC, NLF))
        }
    }
    else
    {
        dash d(depth) dash nl
    }
}

proc count_fgrp(fam, notes)
{
    set(cnt, 13)
    children(fam, ch, nc)
    {
        set(cnt, add(cnt, 3))
        set(cnt, add(cnt, nspouses(ch)))
    }
    set(NLF, cnt)

    call cnt_notes(husband(fam), notes)
    set(NLH, pop(RVAL))

    call cnt_notes(wife(fam), notes)
    set(NLW, pop(RVAL))
}

proc cnt_notes(me, notes)
{
    set(c, 0)
    if (and(me, notes))
    {
        fornodes(inode(me), node)
        {
            if (not(strcmp("NOTE", tag(node))))
            {
                set(c, add(c, 1))
                fornodes(node, next)
                {
                    set(c, add(c, 1))
                }
            }
        }
    }
    if (c) { set(c, add(c, 2)) }
    push(RVAL, c)
}

proc pparent(me, hdr)
{
    if(me)
    {
        call get_refn(me)
        call print_name(me, 1)
        hdr col(10) pop(RVAL) col(55) "[" key(me) "]" col(62) pop(RVAL) nl
        col(6) "B:" col(10) long(birth(me)) nl
        col(6) "D:" col(10) long(death(me)) nl
        call addtoindex(me)
        if (fam, parents(me))
        {
            if (i, husband(fam))
            {
                call get_sdates(i)
                call print_name(i, 1)
                col(10) "FA:" col(15) pop(RVAL) col(60) pop(RVAL) nl
                call addtoindex(i)
            }
            if (i, wife(fam))
            {
                call get_sdates(i)
                call print_name(i, 1)
                col(10) "MO:" col(15) pop(RVAL) col(60) pop(RVAL) nl
                call addtoindex(i)
            }
        }
    }
    else
    {
        hdr nl col(6) "B:" nl col(6) "D:" nl
    }
}

proc pchild(num, me, markme)
{
    if (eq(me, markme)) { set(m, "*") } else { set(m, " ") }
    call print_name(me, 1)
    call rjt(num, 2)
    pop(RVAL) m sex(me) col(8) pop(RVAL) col(55) "[" key(me) "]" nl
    col(6) "B:" col(10) long(birth(me)) nl
    call addtoindex(me)
    spouses(me, sp, fam, nf)
    {
        call print_name(sp, 0)
        call addtoindex(sp)
        col(6) "M:" d(nf) col(10) long(marriage(fam))
            " TO " pop(RVAL) " [" key(sp) "]" nl
    }
    col(6) "D:" col(10) long(death(me)) nl
}

proc print_notes(me, string, nlines)
{
    if (me)
    {
        call paginate_notes(nlines)
        call addtoindex(me)
        set(hdr, 1)
        fornodes( inode(me), node)
        {
            if (not(strcmp("NOTE", tag(node))))
            {
                if (hdr)
                {
                    call print_name(me, 1)
                    string pop(RVAL) " [" key(me) "]" nl
                    set(hdr, 0)
                }
                col(8) value(node) nl
                fornodes(node, next)
                {
                    col(8) value(next) nl
                }
            }
        }
    }
}

proc paginate_notes(nlines)
{
    if (PAGED)
    {
        if (and(gt(nlines, LC), lt(nlines, LPP)))
        {
            set(PAGENO, add(PAGENO, 1))
            ff col(80) "Page: " d(PAGENO) nl
            set(LC, sub(LPP, add(nlines, 1)))
        }
        else
        {
            set(LC, sub(LC, nlines))
        }
    }
}


proc print_name (me, last)
{
    call get_title(me)
    push(RVAL, save(concat(fullname(me, 1, not(last), 45), pop(RVAL))))
}

proc get_refn (me)
{
    fornodes( inode(me), node)
    {
        if (not(strcmp("REFN", tag(node))))
        {
        set(refn, node)
        }
    }
    if (refn) { push(RVAL, save(value(refn))) }
    else { push(RVAL, "") }
}


proc get_title (me)
{
    fornodes(inode(me), node)
    {
        if (not(strcmp("TITL", tag(node)))) { set(n, node) }
    }
    if (n) { push(RVAL, save(concat(" ", value(n)))) }
    else { push(RVAL, "") }
}

proc get_sdates (me)
{
    if (e, birth(me)) { set(b, save(concat("( ", short(e)))) }
        else { set(b, "( ") }
    if (e, death(me)) { set(d, save(concat(" - " , short(e)))) }
        else { set(d, " - ") }
    push(RVAL, save(concat(b, concat(d, " )"))))
}

proc get_ldates (me)
{
    if (e, birth(me)) { set(b, save(concat("( ", long(e)))) }
        else { set(b, "( ") }
    if (e, death(me)) { set(d, save(concat(" - " , long(e)))) }
        else { set(d, " - ") }
    push(RVAL, save(concat(b, concat(d, " )"))))
}

proc get_dates (me)
{
    if (e, birth(me)) { set(b, save(concat("( ", date(e)))) }
        else { set(b, "( ") }
    if (e, death(me)) { set(d, save(concat(" - " , date(e)))) }
        else { set(d, " - ") }
    push(RVAL, save(concat(b, concat(d, " )"))))
}

proc rjt(n, w)
{
    if (lt(n, 10)) { set(d, 1) }
    elsif (lt(n, 100)) { set(d, 2) }
    elsif (lt(n, 1000)) { set(d, 3) }
    elsif (lt(n, 10000)) { set(d, 4) }
    else  { set(d, 5) }
    if (lt(d, w))
        { set(pad, save( trim("      ", sub(w, d)))) }
    else
        { set(pad, "") }
    push(RVAL, save( concat(pad, save(d(n)))))
}