| 1 |
/* |
| 2 |
* @progname sour2.li |
| 3 |
* @version 4.1 |
| 4 |
* @author Paul B. McBride (pbm%[email protected]) |
| 5 |
* @category |
| 6 |
* @output Text |
| 7 |
* @description |
| 8 |
|
| 9 |
report program subroutine library for handling SOURces. |
| 10 |
|
| 11 |
add the following lines to your source program to use this library of |
| 12 |
routines: |
| 13 |
|
| 14 |
include("quicksort.ll") |
| 15 |
include("compare.ll") [define your own compare if necessary] |
| 16 |
include("sour.li") |
| 17 |
include("html.ll") |
| 18 |
|
| 19 |
27-feb-96 v4.1 - Indent PUBL info properly. Set source to LDS-AF if AFN seen. |
| 20 |
14-feb-96 v4 - Use quicksort() to sort sources by REFN value |
| 21 |
08-feb-96 v3 - Support REPO records |
| 22 |
24-jan-96 v1.2 - GEDCOM 5.5 support and compatibility notes |
| 23 |
Correct processing of Sources without REFN tags |
| 24 |
03-oct-95 v1.1 - sour_addset() now adds sources for families of individuals |
| 25 |
|
| 26 |
Requirements: |
| 27 |
LifeLines 3.0.2 or later (I hope) |
| 28 |
|
| 29 |
Future modifications: |
| 30 |
- Add routines to report sources as references to footnotes, and |
| 31 |
list sources in foot notes. Also report source citation detail |
| 32 |
(PAGE, NOTE). |
| 33 |
- Add support for repository records (REPO) to replace non standard |
| 34 |
location (LOCA) records. |
| 35 |
|
| 36 |
See Examples of using the library routines below. |
| 37 |
|
| 38 |
Tags within SOUR definitions which are processed by sour_ref(): |
| 39 |
|
| 40 |
GEDCOM Non Standard |
| 41 |
5.5 |
| 42 |
|
| 43 |
REFN see below |
| 44 |
TITL title |
| 45 |
AUTH author |
| 46 |
PUBL publisher information |
| 47 |
DATE publication date |
| 48 |
EDIT which edition, revision, etc |
| 49 |
VOLU number of volumnes (e.g. 3 vols) |
| 50 |
PAGE page numbers |
| 51 |
PLAC place of publication |
| 52 |
REPO LOCA where you saw this source (repository) |
| 53 |
NOTE notes |
| 54 |
TEXT text quoted from document |
| 55 |
|
| 56 |
The GEDCOM 5.5 standard combines all of the publication related info |
| 57 |
into the PUBL tag line with continuations (CONT). It introduces |
| 58 |
a repository structure which includes the NAME and address (ADDR structure) |
| 59 |
of the location where the source can be viewed. |
| 60 |
|
| 61 |
The following describes how I use the REFN tag. This is not particularly |
| 62 |
relevant, but here goes. |
| 63 |
|
| 64 |
There are some standard abbreviations that are often used: |
| 65 |
MD Mayflower Descendant |
| 66 |
NEHGR New England Historic Genealogical Society Register |
| 67 |
TAG The Americant Genealogist |
| 68 |
RFC Royalty for Commoners |
| 69 |
AR7 Ancestral Roots... 7th edition |
| 70 |
I use other REFN's which are a combination of the subject, or author |
| 71 |
and a suffix: |
| 72 |
WentworthG Wentworth Genealogy |
| 73 |
HayesFH a Hayes family history |
| 74 |
ScituateVR Scituate, MA Vital Records |
| 75 |
HamptonTH Hampton, NH Town History |
| 76 |
|
| 77 |
When I am entering a source field I would then enter it as: |
| 78 |
|
| 79 |
2 SOUR <WentworthG> |
| 80 |
|
| 81 |
and it will get converted to |
| 82 |
|
| 83 |
2 @Sxxx@ SOUR |
| 84 |
|
| 85 |
Examples: |
| 86 |
|
| 87 |
1) Report references used in a set of individuals |
| 88 |
|
| 89 |
include("sour.li") |
| 90 |
... |
| 91 |
call sour_init() / * initialize the current source list and table * / |
| 92 |
... / * create a set of individuals * / |
| 93 |
call sour_addset(a_set) / * add all sources referenced by set * / |
| 94 |
"References: " nl() nl() |
| 95 |
call sour_ref(10) / * report details of all sources * / |
| 96 |
|
| 97 |
2) List references for groups of individuals, and then a master |
| 98 |
list of all sources referenced: |
| 99 |
|
| 100 |
include("sour.li") |
| 101 |
... |
| 102 |
table(my_table) |
| 103 |
list(my_list) |
| 104 |
...for each group of individuals |
| 105 |
{ call sour_init() / * initialize the current source list and table * / |
| 106 |
...for each individual... |
| 107 |
{ call sour_addind(an_indi) |
| 108 |
if(sour_exists()) { |
| 109 |
"References: " |
| 110 |
call sour_see(",", 70, 10) / * report REFN of each source * / |
| 111 |
call sour_save(my_table, my_list) / * add to master list * / |
| 112 |
} |
| 113 |
} |
| 114 |
} |
| 115 |
/ * make master list the current list of sources * / |
| 116 |
call sour_restore(my_table, my_list) |
| 117 |
if(sour_exists()) { |
| 118 |
"Key to References:" nl() nl() |
| 119 |
call sour_ref(10) / * report details for all sources * / |
| 120 |
} |
| 121 |
|
| 122 |
3) Output all sources for a set of individuals in GEDCOM format: |
| 123 |
|
| 124 |
include("sour.li") |
| 125 |
... |
| 126 |
call sour_init() / * initialize the current source list and table * / |
| 127 |
... / * create a set of individuals * / |
| 128 |
call sour_addset(a_set) / * add all sources referenced by set * / |
| 129 |
call sour_ged() / * output sources in GEDCOM format * / |
| 130 |
|
| 131 |
08-sep-95 Paul B. McBride (pbm%[email protected]) |
| 132 |
*/ |
| 133 |
|
| 134 |
global(sour_list) |
| 135 |
global(sour_table) |
| 136 |
|
| 137 |
proc sour_init() |
| 138 |
{ |
| 139 |
table(sour_table) |
| 140 |
list(sour_list) |
| 141 |
} |
| 142 |
|
| 143 |
proc sour_save(t, l) |
| 144 |
{ |
| 145 |
forlist(sour_list, v, n) { |
| 146 |
if (eq(0, lookup(t, v))) { |
| 147 |
insert(t, v, 1) |
| 148 |
enqueue(l, v) |
| 149 |
} |
| 150 |
} |
| 151 |
} |
| 152 |
|
| 153 |
proc sour_restore(t, l) |
| 154 |
{ |
| 155 |
set(sour_table, t) |
| 156 |
set(sour_list, l) |
| 157 |
} |
| 158 |
|
| 159 |
/* sour_add() adds the sources referenced for this individual. This |
| 160 |
will also work for families |
| 161 |
*/ |
| 162 |
|
| 163 |
proc sour_addind(i) |
| 164 |
{ |
| 165 |
traverse(root(i), m, l) { |
| 166 |
set(v, 0) |
| 167 |
if (eqstr("AFN", tag(m))) { |
| 168 |
set(v, "LDS-AF") |
| 169 |
} |
| 170 |
elsif (eqstr("SOUR", tag(m))) { |
| 171 |
set(v, value(m)) |
| 172 |
if(not(reference(v))) { set(v, 0) } |
| 173 |
} |
| 174 |
if(v) { |
| 175 |
if (ne(0, lookup(sour_table, v))) { continue() } |
| 176 |
set(v, save(v)) |
| 177 |
insert(sour_table, v, 1) |
| 178 |
enqueue(sour_list, v) |
| 179 |
} |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
proc sour_addset(s) |
| 184 |
{ |
| 185 |
forindiset (s, i, a, n) { |
| 186 |
call sour_addind(i) |
| 187 |
families(i, f, sp, m) { |
| 188 |
call sour_addind(f) |
| 189 |
} |
| 190 |
} |
| 191 |
} |
| 192 |
|
| 193 |
proc sour_see(sep, maxlen, indent) |
| 194 |
{ |
| 195 |
set(first, 1) |
| 196 |
set(curlen, indent) |
| 197 |
set(seplen, strlen(sep)) |
| 198 |
forlist(sour_list, k, n) { |
| 199 |
if(first) { set(first, 0) } |
| 200 |
else { |
| 201 |
sep |
| 202 |
set(curlen, add(curlen, seplen)) |
| 203 |
} |
| 204 |
if(eqstr(k, "LDS-AF")) { set(myrefn, k) } |
| 205 |
else { |
| 206 |
set(myrefn, sour_getfield(dereference(k), "REFN")) |
| 207 |
if(eq(myrefn, 0)) { set(myrefn, k) } |
| 208 |
} |
| 209 |
set(mylen, add(add(strlen(myrefn), seplen),2)) |
| 210 |
if(and(gt(maxlen, 0), gt(add(curlen, mylen), maxlen))) { |
| 211 |
col(indent) |
| 212 |
set(curlen, indent) |
| 213 |
} |
| 214 |
call html_lt() /* < */ |
| 215 |
if(eq(html_ext, 0)) { set(html_ext, ".html") } |
| 216 |
call html_ahref("ref", html_ext, myrefn) |
| 217 |
myrefn |
| 218 |
call html_tag("/A", 0) |
| 219 |
call html_gt() /* > */ |
| 220 |
set(curlen, add(curlen, mylen)) |
| 221 |
} |
| 222 |
|
| 223 |
if(and(HTML, eq(first,0))) { |
| 224 |
call html_tag("P", 1) |
| 225 |
} |
| 226 |
} |
| 227 |
|
| 228 |
proc sour_ref(colnum) |
| 229 |
{ |
| 230 |
list(alist) |
| 231 |
list(ilist) |
| 232 |
|
| 233 |
/* build list of reference keys */ |
| 234 |
forlist(sour_list, k, n) { |
| 235 |
if(eqstr(k, "LDS-AF")) { set(refn, k) } |
| 236 |
else { |
| 237 |
set(anode, dereference(k)) |
| 238 |
set(refn, sour_getfield(anode, "REFN")) |
| 239 |
if(eq(refn, 0)) { set(refn, k) } |
| 240 |
} |
| 241 |
enqueue(alist, save(refn)) |
| 242 |
} |
| 243 |
|
| 244 |
/* sort the list */ |
| 245 |
call quicksort(alist, ilist) |
| 246 |
|
| 247 |
/* report */ |
| 248 |
call html_tag("UL", 0) |
| 249 |
while(n, dequeue(ilist)) { |
| 250 |
set(ldsaf, 0) |
| 251 |
set(k, getel(sour_list, n)) |
| 252 |
call html_tag("LI", 0) |
| 253 |
call html_tag("PRE", 1) |
| 254 |
if(eqstr(k, "LDS-AF")) { set(refn, k) set(ldsaf, 1) } |
| 255 |
else { |
| 256 |
set(anode, dereference(k)) |
| 257 |
set(refn, sour_getfield(anode, "REFN")) |
| 258 |
if(eq(refn, 0)) { set(refn, k) } |
| 259 |
} |
| 260 |
call html_lt() /* < */ |
| 261 |
refn |
| 262 |
call html_gt() /* > */ |
| 263 |
col(colnum) |
| 264 |
qt() |
| 265 |
if(ldsaf) { "LDS Ancestral File" } |
| 266 |
else {sour_repfield(anode, "TITL", colnum) } |
| 267 |
qt() |
| 268 |
if(HTML) { |
| 269 |
call html_aname(refn) |
| 270 |
} |
| 271 |
if(ldsaf) { "." nl() } |
| 272 |
else { |
| 273 |
if(sour_getfield(anode, "AUTH")) { |
| 274 |
"," nl() |
| 275 |
col(colnum) |
| 276 |
sour_repfield(anode, "AUTH", colnum) |
| 277 |
} |
| 278 |
set(d, sour_getfield(anode, "DATE")) |
| 279 |
if(d) { ", " d } |
| 280 |
set(d, sour_getfield(anode, "EDIT")) |
| 281 |
if(d) { ", " d } |
| 282 |
set(d, sour_getfield(anode, "VOLU")) |
| 283 |
if(d) { ", " d } |
| 284 |
set(d, sour_getfield(anode, "PAGE")) |
| 285 |
if(d) { ", " d } |
| 286 |
set(d, sour_getfield(anode, "PUBL")) |
| 287 |
if(d) { ", " nl() col(colnum) d } |
| 288 |
set(d, sour_getfield(anode, "PLAC")) |
| 289 |
if(d) { ", " d } |
| 290 |
"." nl() |
| 291 |
if(html_urls(anode, colnum)) { nl() } |
| 292 |
if(sour_getfield(anode, "NOTE")) { |
| 293 |
col(colnum) |
| 294 |
sour_repfield(anode, "NOTE", colnum) |
| 295 |
nl() |
| 296 |
} |
| 297 |
if(sour_getfield(anode, "TEXT")) { |
| 298 |
col(colnum) |
| 299 |
sour_repfield(anode, "TEXT", colnum) |
| 300 |
nl() |
| 301 |
} |
| 302 |
} |
| 303 |
call html_tag("/PRE", 0) |
| 304 |
call html_tag("/LI", 0) |
| 305 |
} |
| 306 |
call html_tag("/UL", 0) |
| 307 |
} |
| 308 |
|
| 309 |
func sour_exists() |
| 310 |
{ |
| 311 |
return(ne(length(sour_list), 0)) |
| 312 |
} |
| 313 |
|
| 314 |
func sour_getfield(r, t) |
| 315 |
{ |
| 316 |
traverse(r, s, l) { |
| 317 |
if (eq(0, strcmp(t, tag(s)))) { return(value(s)) } |
| 318 |
} |
| 319 |
return(0) |
| 320 |
} |
| 321 |
|
| 322 |
func sour_repfield(r, t, colnum) |
| 323 |
{ |
| 324 |
set(found, 0) |
| 325 |
fornodes(r, node) { |
| 326 |
if (eq(0,strcmp(t, tag(node)))) { |
| 327 |
set(found, 1) |
| 328 |
value(node) |
| 329 |
fornodes(node, subnode) { |
| 330 |
if (eq(0,strcmp("CONT", tag(subnode)))) { |
| 331 |
nl() |
| 332 |
if(gt(colnum, 0)) { col(colnum) } |
| 333 |
value(subnode) |
| 334 |
} |
| 335 |
} |
| 336 |
break() |
| 337 |
} |
| 338 |
} |
| 339 |
return(found) |
| 340 |
} |
| 341 |
|
| 342 |
/* sour_ged() outputs the current source list in GEDCOM format */ |
| 343 |
|
| 344 |
proc sour_ged() |
| 345 |
{ |
| 346 |
table(other_table) |
| 347 |
list(other_list) |
| 348 |
|
| 349 |
forlist(sour_list, k, n) { |
| 350 |
if(reference(k)) { |
| 351 |
set(r, dereference(k)) |
| 352 |
traverse(r, s, l) { |
| 353 |
d(l) |
| 354 |
if (xref(s)) { " " xref(s) } |
| 355 |
" " tag(s) |
| 356 |
if (v, value(s)) { |
| 357 |
" " v |
| 358 |
if(reference(v)) { |
| 359 |
if (ne(0, lookup(other_table, v))) { continue() } |
| 360 |
set(v, save(v)) |
| 361 |
insert(other_table, v, 1) |
| 362 |
enqueue(other_list, v) |
| 363 |
} |
| 364 |
} |
| 365 |
"\n" |
| 366 |
} |
| 367 |
} |
| 368 |
} |
| 369 |
forlist(other_list, k, n) { |
| 370 |
set(r, dereference(k)) |
| 371 |
traverse(r, s, l) { |
| 372 |
d(l) |
| 373 |
if (xref(s)) { " " xref(s) } |
| 374 |
" " tag(s) |
| 375 |
if (v, value(s)) { " " v } |
| 376 |
"\n" |
| 377 |
} |
| 378 |
} |
| 379 |
} |