Debian Codegraph @

reports/sour.li

raw
1 /*
2 * @progname sour.li
3 * @version 1995-09-08
4 * @author Paul B. McBride (pbm%[email protected])
5 * @category
6 * @output Text
7 * @description
8
9 functions for handling SOURces.
10
11 Requirements:
12 LifeLines 3.0.2 or later (I hope)
13
14 See Examples of using the library routines below.
15
16 Tags within SOUR definitions which are processed by sour_ref():
17
18 REFN see below
19 TITL title
20 AUTH author
21 DATE publication date
22 EDIT which edition, revision, etc
23 VOLU number of volumnes (e.g. 3 vols)
24 PAGE page numbers
25 PUBL publisher
26 PLAC place of publication
27 LOCA where did you saw this source
28
29 The following describes how I use the REFN tag. This is not particularly
30 relevant, but here goes.
31
32 There are some standard abbreviations that are often used:
33 MD Mayflower Descendant
34 NEHGR New England Historic Genealogical Society Register
35 TAG The Americant Genealogist
36 RFC Royalty for Commoners
37 AR7 Ancestral Roots... 7th edition
38 I use other REFN's which are a combination of the subject, or author
39 and a suffix:
40 WentworthG Wentworth Genealogy
41 HayesFH a Hayes family history
42 ScituateVR Scituate, MA Vital Records
43 HamptonTH Hampton, NH Town History
44
45 When I am entering a source field I would then enter it as:
46
47 2 SOUR <WentworthG>
48
49 and it will get converted to
50
51 2 @Sxxx@ SOUR
52
53 Examples:
54
55 1) Report references used in a set of individuals
56
57 include("sour.ll")
58 ...
59 sour_init() / * initialize the current source list and table * /
60 ... / * create a set of individuals * /
61 sour_addset(a_set) / * add all sources referenced by set * /
62 "References: "
63 sour_ref(13) / * output sources in GEDCOM format * /
64
65 2) List references for groups of individuals, and then a master
66 list of all sources referenced:
67
68 include("sour.ll")
69 ...
70 table(my_table)
71 list(my_list)
72 ...for each group of individuals
73 { sour_init() / * initialize the current source list and table * /
74 ...for each individual...
75 { sour_addind(an_indi)
76 if(sour_exists()) {
77 "References: "
78 sour_see(",", 70, 10) / * report REFN of each source * /
79 sour_save(my_table, my_list) / * add to master list * /
80 }
81 }
82 }
83 sour_restore(my_table, my_list) / * make master list the current one * /
84 if(sour_exists()) {
85 "Key to References:" nl() nl()
86 sour_ref(10) / * report details for all sources * /
87 }
88
89 3) Output all sources for a set of individuals in GEDCOM format:
90
91 include("sour.ll")
92 ...
93 sour_init() / * initialize the current source list and table * /
94 ... / * create a set of individuals * /
95 sour_addset(a_set) / * add all sources referenced by set * /
96 sour_ged() / * output sources in GEDCOM format * /
97
98 08-sep-95 Paul B. McBride (pbm%[email protected])
99 */
100
101 global(sour_list)
102 global(sour_table)
103
104 proc sour_init()
105 {
106 table(sour_table)
107 list(sour_list)
108 }
109
110 proc sour_save(t, l)
111 {
112 forlist(sour_list, v, n) {
113 if (eq(0, lookup(t, v))) {
114 insert(t, v, 1)
115 enqueue(l, v)
116 }
117 }
118 }
119
120 proc sour_restore(t, l)
121 {
122 set(sour_table, t)
123 set(sour_list, l)
124 }
125
126 /* sour_add() adds the sources referenced for this individual */
127
128 proc sour_addind(i)
129 {
130 traverse(root(i), m, l) {
131 if (nestr("SOUR", tag(m))) { continue() }
132 set(v, value(m))
133 if(reference(v)) {
134 if (ne(0, lookup(sour_table, v))) { continue() }
135 set(v, save(v))
136 insert(sour_table, v, 1)
137 enqueue(sour_list, v)
138 }
139 }
140 }
141
142 proc sour_addset(s)
143 {
144 forindiset (s, i, a, n) {
145 call sour_addind(i)
146 }
147 }
148
149 proc sour_see(sep, maxlen, indent)
150 {
151 set(first, 1)
152 set(curlen, indent)
153 set(seplen, strlen(sep))
154 forlist(sour_list, k, n) {
155 if(first) { set(first, 0) }
156 else {
157 sep
158 set(curlen, add(curlen, seplen))
159 }
160 set(myrefn, sour_getfield(dereference(k), "REFN"))
161 set(mylen, add(add(strlen(myrefn), seplen),2))
162 if(and(gt(maxlen, 0), gt(add(curlen, mylen), maxlen))) {
163 col(indent)
164 set(curlen, indent)
165 }
166 "<" myrefn ">"
167 set(curlen, add(curlen, mylen))
168 }
169 }
170
171 proc sour_ref(colnum)
172 {
173 forlist(sour_list, k, n) {
174 set(n, dereference(k))
175 "<" sour_getfield(n, "REFN") ">" col(colnum)
176 qt()
177 sour_repfield(n, "TITL", colnum)
178 qt()
179 if(sour_getfield(n, "AUTH")) {
180 "," nl()
181 col(colnum)
182 sour_repfield(n, "AUTH", colnum)
183 }
184 set(d, sour_getfield(n, "DATE"))
185 if(d) { ", " d }
186 set(d, sour_getfield(n, "EDIT"))
187 if(d) { ", " d }
188 set(d, sour_getfield(n, "VOLU"))
189 if(d) { ", " d }
190 set(d, sour_getfield(n, "PAGE"))
191 if(d) { ", " d }
192 set(d, sour_getfield(n, "PUBL"))
193 if(d) { ", " nl() d }
194 set(d, sour_getfield(n, "PLAC"))
195 if(d) { ", " d }
196 "." nl()
197 if(sour_getfield(n, "NOTE")) {
198 col(colnum)
199 sour_repfield(n, "NOTE", colnum)
200 nl()
201 }
202 }
203 }
204
205 func sour_exists()
206 {
207 return(ne(length(sour_list), 0))
208 }
209
210 func sour_getfield(r, t)
211 {
212 traverse(r, s, l) {
213 if (eq(0, strcmp(t, tag(s)))) { return(value(s)) }
214 }
215 return(0)
216 }
217
218 func sour_repfield(r, t, colnum)
219 {
220 set(found, 0)
221 fornodes(r, node) {
222 if (eq(0,strcmp(t, tag(node)))) {
223 set(found, 1)
224 value(node)
225 fornodes(node, subnode) {
226 if (eq(0,strcmp("CONT", tag(subnode)))) {
227 nl()
228 if(gt(colnum, 0)) { col(colnum) }
229 value(subnode)
230 }
231 }
232 break()
233 }
234 }
235 return(found)
236 }
237
238 /* sour_ged() outputs the current source list in GEDCOM format */
239
240 proc sour_ged()
241 {
242 forlist(sour_list, k, n) {
243 set(r, dereference(k))
244 traverse(r, s, l) {
245 d(l)
246 if (xref(s)) { " " xref(s) }
247 " " tag(s)
248 if (value(s)) { " " value(s) }
249 "\n"
250 }
251 }
252 }