File: htmlfam.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 (167 lines) | stat: -rw-r--r-- 4,259 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
/*
 * @progname       htmlfam.ll
 * @version        3
 * @author         Tom Wetmore (ttw@shore.net)
 * @category       
 * @output         HTML
 * @description
 *
 * output family group summaries in HTML format
 */

/* third draft -- 12/27/95 -- Tom Wetmore -- ttw@shore.net */

global(pert)    /* person table */
global(showf)   /* families that have been shown */

proc main ()
{
        getindi(per0, "Who do you want to start with?")
        set(fam0, parents(per0))
        list(perq)
        list(famq)
        table(pert)
        list(lst)
        insert(pert, save(key(per0)), lst)
        table(showf)

        enqueue(perq, per0)
        while (per, dequeue(perq)) {
                if (fam, parents(per)) {
                        if (per, husband(fam)) {
                                call makelink(per, fam)
                                enqueue(perq, per)
                        }
                        if (per, wife(fam)) {
                                call makelink(per, fam)
                                enqueue(perq, per)
                        }
                }
        }
        call showhead()
        call showper(per0)
        enqueue(famq, fam0)
        while (fam, dequeue(famq)) {
                if (not(lookup(showf, key(fam)))) {
                        call showfam(fam)
                        insert(showf, save(key(fam)), 1)
                }
                set(husb, husband(fam))
                set(wife, wife(fam))
                if (fam, parents(husb)) { enqueue(famq, fam) }
                if (fam, parents(wife)) { enqueue(famq, fam) }
        }
        call showtail()
}

proc makelink (per, fam)
{
        if (lst, lookup(pert, key(per))) {
                call enqueueifnew(lst, key(fam))
        } else {
                list(lst)
                enqueue(lst, save(key(fam)))
                insert(pert, save(key(per)), lst)
        }
}

proc enqueueifnew (lst, key)
{
        forlist (lst, el, num) {
                if (eqstr(key, el)) { return() }
        }
        enqueue(lst, save(key))
}

proc showper (per)
{
        call showone(per)
        families(per, fam, sp, num) {
                call showone(sp)
                call showmarr(fam)
                call showchildren(fam)
        }
        "<HR>\n"
}

proc showfam (fam)
{
        "<A NAME=\"" key(fam) "\"></A>\n"
        call showone(husband(fam))
        call showone(wife(fam))
        call showmarr(fam)
        call showchildren(fam)
        "<HR>\n"
}

proc showone (per)
{
        if (not(per)) { return() }
        "<P><STRONG>"name(per, 0)"</STRONG>\n"
        if (evt, birth(per)) { "<BR>born "long(evt)"\n" }
        if (evt, death(per)) { "<BR>died "long(evt)"\n" }
        set(fam, parents(per))
        if (par, father(per)) {
                "<BR>father " call showlink(par, key(fam)) "\n"
        }
        if (par, mother(per)) {
                "<BR>mother " call showlink(par, key(fam)) "\n"
        }
}

proc showmarr (fam)
{
        if (evt, marriage(fam)) { "<BR>married "long(evt)"\n" }
}

proc showchildren (fam)
{
        if (eq(0, nchildren(fam))) { return() }
        "<P><STRONG>Children</STRONG>\n"
        children (fam, per, num) {
                "<BR>" d(num) " " call showchild(per) "\n"
        }
}

proc showlink (per, key) {
        set(lst, lookup(pert, key(per)))
        if (lst) { "<A HREF=\"#" key "\">" }
        name(per, 0)
        if (lst) { "</A>" }
        call showevents(per)
}

proc showchild (per) {
        if (lst, lookup(pert, key(per))) {
                call showlinks(per, lst)
        } else {
                name(per, 0)
                call showevents(per)
        }
}

proc showlinks (per, lst) /* LOOSEEND -- THIS ROUTINE NEEDS MORE */
{
        if (eq(0, length(lst))) {
                call showlink(per, "start")
        } else {
                call showlink(per, getel(lst, 1))
        }
}

proc showevents (per)
{
        set(evt, birth(per))
        if (and(evt, year(evt))) { ", b " year(evt) }
        set(evt, death(per))
        if (and(evt, year(evt))) { ", d " year(evt) }
}

proc showhead () {
        "<HTML><HEAD><TITLE>Genealogy Page</TITLE></HEAD>\n<BODY>\n"
        "<A NAME=\"start\"></A>\n"
}

proc showtail () {
        "</BODY></HTML>\n"
}