| 1 |
/* |
| 2 |
* @progname allines.sgml.ll |
| 3 |
* @version 1.1 |
| 4 |
* @author Wetmore, Nozell |
| 5 |
* @category |
| 6 |
* @output SGML, NROFF |
| 7 |
* @description |
| 8 |
* |
| 9 |
* This program shows all ancestral lines of a specified person |
| 10 |
* using a pseudo-Register format. |
| 11 |
* |
| 12 |
* Output is in nroff or sgml format. This may change to something |
| 13 |
* more generic. |
| 14 |
* |
| 15 |
* Tom Wetmore, [email protected] |
| 16 |
* beta version, 27 February 1997 |
| 17 |
* |
| 18 |
* Marc Nozell, [email protected] |
| 19 |
* Added sgmldoc (formerly known as linuxdoc), 3 March 1997 |
| 20 |
*/ |
| 21 |
|
| 22 |
global(format_type) /* what format? nroff or sgml? */ |
| 23 |
global(CurID) /* ID values assigned to ancestors */ |
| 24 |
global(BOLK) /* list of keys of persons who begin lines */ |
| 25 |
global(BOLG) /* generations of begin line persons */ |
| 26 |
global(BOLR) /* relationships of begin line persons */ |
| 27 |
global(CurK) /* current line being processed */ |
| 28 |
global(CurG) /* generations in current line */ |
| 29 |
global(CurR) /* relations in current line */ |
| 30 |
global(AncT) /* table of all ancestors */ |
| 31 |
global(AncL) /* list of all ancestors */ |
| 32 |
global(KeyT) /* table of all saved keys */ |
| 33 |
global(TOLT) /* table of top of line persons */ |
| 34 |
global(TOLL) /* list of top of line persons */ |
| 35 |
global(FamT) /* NEED COMMENT TO DESCRIBE THIS!! */ |
| 36 |
|
| 37 |
/* User Options */ |
| 38 |
|
| 39 |
global(OPat) /* follow paternal lines */ |
| 40 |
global(ORel) /* show relationships */ |
| 41 |
|
| 42 |
/* LineParent -- Return parent in line direction. */ |
| 43 |
|
| 44 |
func LineParent (p) |
| 45 |
{ |
| 46 |
if (OPat) { return(father(p)) } |
| 47 |
else { return(mother(p)) } |
| 48 |
} |
| 49 |
|
| 50 |
/* OthrParent -- Return parent in non-line direction. */ |
| 51 |
|
| 52 |
func OthrParent (p) |
| 53 |
{ |
| 54 |
if (OPat) { return(mother(p)) } |
| 55 |
else { return(father(p)) } |
| 56 |
} |
| 57 |
|
| 58 |
/* |
| 59 |
* main - This is the main routine; it asks the user to identify a person |
| 60 |
* and then calls the DoIt routine. |
| 61 |
*/ |
| 62 |
|
| 63 |
proc main () |
| 64 |
{ |
| 65 |
getindi(i, "Enter person whose full registry ancestry is wanted.") |
| 66 |
if (i) { call DoIt(i) } |
| 67 |
else { print("Program not run.") } |
| 68 |
} |
| 69 |
|
| 70 |
/* |
| 71 |
* DoIt - This is the top routine of the program; it calls routines to |
| 72 |
* perform the main algorithmic jobs and then calls a routine to write the |
| 73 |
* report. |
| 74 |
*/ |
| 75 |
|
| 76 |
proc DoIt (i) |
| 77 |
{ |
| 78 |
set(CurID, 1) |
| 79 |
table(KeyT) |
| 80 |
call GetUserOptions() |
| 81 |
|
| 82 |
/* |
| 83 |
* The first step in this program is to compute the list of "bottom of |
| 84 |
* line" persons. These persons are those that on first sight seem to |
| 85 |
* require an ancestral line generated in the program's output. Because |
| 86 |
* multiple bottom of line persons may have the same top of line ancestor |
| 87 |
* (due to pedigree collapse) it may turn out that there is not a separate |
| 88 |
* line computed for each bottom of line person. This complication is |
| 89 |
* dealt with later. The first bottom of line person is always the |
| 90 |
* starting person, and the first ancestral line shown in the output will |
| 91 |
* be the parental line of this person. Normally this parental line will |
| 92 |
* be the paternal line. |
| 93 |
*/ |
| 94 |
print("Finding all bottom of line persons.\n") |
| 95 |
call BFirstCreateBOLLists(i)/**/ |
| 96 |
/* call ShowBOLLists() /*DEBUG*/ |
| 97 |
|
| 98 |
/* |
| 99 |
* The second step is to build an ancestor table that contains all the |
| 100 |
* information about the ancestors of the key person that is needed in |
| 101 |
* generating the program's output. The table accumulates the information |
| 102 |
* needed to deal with pedigree collapse. |
| 103 |
*/ |
| 104 |
|
| 105 |
print("Creating table of all ancestors.\n") |
| 106 |
call CreateAncStructures() /* call ShowAncTable() /**/ |
| 107 |
|
| 108 |
/* |
| 109 |
* The third step is to number the ancestors in the ancestor table in such |
| 110 |
* a way that on output each numbered ancestor magically has the right |
| 111 |
* sequential number. |
| 112 |
*/ |
| 113 |
|
| 114 |
print("Numbering all ancestors in table.\n") |
| 115 |
call NumberAncestors() /* call ShowAncTable() /**/ |
| 116 |
|
| 117 |
/* |
| 118 |
* The fourth step is to compute the list of top of line ancestors. Due |
| 119 |
* to pedigree collapse there may be fewer top of line ancestors than |
| 120 |
* there are bottom of line persons. Whenever this is the case, there |
| 121 |
* will be an ancestor somewhere in the line who has more than one child |
| 122 |
* who are also ancestors (the essence of pedigree collapse). This program |
| 123 |
* collapses all lines that begin with the same person but lead to |
| 124 |
* different descendants (who are still all ancestors of the starting |
| 125 |
* person) |
| 126 |
*/ |
| 127 |
|
| 128 |
print("Computing top of line ancestors.\n") |
| 129 |
call CreateTOLList() /* call ShowTOLList() /**/ |
| 130 |
|
| 131 |
/* |
| 132 |
* The last step is to write the report. |
| 133 |
*/ |
| 134 |
|
| 135 |
print("Printing final report.\n") |
| 136 |
call WriteReport() |
| 137 |
} |
| 138 |
|
| 139 |
/* |
| 140 |
* GetUserOptions - As you can see, users can't actually select them yet! |
| 141 |
*/ |
| 142 |
|
| 143 |
proc GetUserOptions () |
| 144 |
{ |
| 145 |
getintmsg(format_type, "Enter 0 for nroff, 1 for sgml") |
| 146 |
|
| 147 |
set(OPat, 1) /* this version only follows paternal lines */ |
| 148 |
set(ORel, 1) /* this version shows relationships */ |
| 149 |
} |
| 150 |
|
| 151 |
/* |
| 152 |
* BFirstCreateBOLLists - This routine creates the beginning of lines lists. |
| 153 |
* This is the breadth first version of this routine. Following is the |
| 154 |
* moving front version. I don't know which order is the best. Try them |
| 155 |
* both and see which you prefer. |
| 156 |
*/ |
| 157 |
|
| 158 |
proc BFirstCreateBOLLists (i) |
| 159 |
{ |
| 160 |
list(BOLK) list(BOLG) list(BOLR) |
| 161 |
list(TmpK) list(TmpG) list(TmpR) |
| 162 |
enqueue(TmpK, savekey(key(i))) |
| 163 |
enqueue(TmpG, 1) enqueue(TmpR, 1) |
| 164 |
|
| 165 |
while (k, dequeue(TmpK)) { |
| 166 |
set(p, indi(k)) |
| 167 |
set(g, dequeue(TmpG)) set(r, dequeue(TmpR)) |
| 168 |
if (eq(1, mod(r, 2))) { |
| 169 |
enqueue(BOLK, k) enqueue(BOLG, g) enqueue(BOLR, r) |
| 170 |
} |
| 171 |
set(g, add(1, g)) set(r, mul(2, r)) |
| 172 |
if (f, LineParent(p)) { |
| 173 |
enqueue(TmpK, savekey(key(f))) |
| 174 |
enqueue(TmpG, g) enqueue(TmpR, r) |
| 175 |
} |
| 176 |
set(r, add(1, r)) |
| 177 |
if (m, OthrParent(p)) { |
| 178 |
enqueue(TmpK, savekey(key(m))) |
| 179 |
enqueue(TmpG, g) enqueue(TmpR, r) |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
/* |
| 185 |
* MFrontCreateBOLLists - This routine also creates the beginning of line |
| 186 |
* lists. This is the moving front version, and is not used in this beta |
| 187 |
* version. |
| 188 |
*/ |
| 189 |
|
| 190 |
proc MFrontCreateBOLLists (i) |
| 191 |
{ |
| 192 |
list(BOLK) list(BOLG) list(BOLR) |
| 193 |
list(TmpK) list(TmpG) list(TmpR) |
| 194 |
enqueue(TmpK, savekey(key(i))) |
| 195 |
enqueue(TmpG, 1) enqueue(TmpR, 1) |
| 196 |
|
| 197 |
while (k, dequeue(TmpK)) { |
| 198 |
set(g, dequeue(TmpG)) set(r, dequeue(TmpR)) |
| 199 |
set(p, indi(k)) |
| 200 |
enqueue(BOLK, k) enqueue(BOLG, g) enqueue(BOLR, r) |
| 201 |
while (p) { |
| 202 |
set(g, add(g, 1)) set(r, mul(r, 2)) |
| 203 |
if (m, OthrParent(p)) { |
| 204 |
enqueue(TmpK, savekey(key(m))) |
| 205 |
enqueue(TmpG, g) enqueue(TmpR, add(r, 1)) |
| 206 |
} |
| 207 |
set(p, LineParent(p)) |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
/* |
| 213 |
* CreateAncStructures - This routine creates the AncT table and AncL list. |
| 214 |
* These are data structures that hold information about all ancestors of |
| 215 |
* the starting person. This routine operates by considering each bottom |
| 216 |
* of line person in turn. For each bottom of line person his or her |
| 217 |
* ancestral line is computed and then the ProcessCurLine routine is |
| 218 |
* called. It is the ProcessCurLine routine that actually updates the |
| 219 |
* data structures. |
| 220 |
* |
| 221 |
* Note that the only use of the AncL list is in the debugging routine |
| 222 |
* ShowAncTable. |
| 223 |
*/ |
| 224 |
|
| 225 |
proc CreateAncStructures () |
| 226 |
{ |
| 227 |
table(AncT) list(AncL) |
| 228 |
|
| 229 |
forlist(BOLK, k, n) { /* for each bottom of line person ... */ |
| 230 |
set(g, getel(BOLG, n)) set(r, getel(BOLR, n)) |
| 231 |
set(p, indi(k)) |
| 232 |
|
| 233 |
list(CurK) list(CurG) list(CurR) /* make them empty */ |
| 234 |
while (p) { /* start with BOL person and follow line back */ |
| 235 |
push(CurK, savekey(key(p))) |
| 236 |
push(CurG, g) push(CurR, r) |
| 237 |
set(g, add(1, g)) |
| 238 |
set(r, mul(2, r)) |
| 239 |
set(p, LineParent(p)) |
| 240 |
} |
| 241 |
call ProcessCurLine() |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
/* |
| 246 |
* ProcessCurLine - This routine updates the ancestor table and list based |
| 247 |
* on an ancestral line just computed for a bottom of line person by the |
| 248 |
* CreateAncStructures routine. This line is stored in the three global |
| 249 |
* lists CurK, CurG, and CurR, which form the interface between this |
| 250 |
* routine and CreateAncStructures. This routine processes the line from |
| 251 |
* the last line ancestor of the bottom of line person to the bottom of |
| 252 |
* line person. |
| 253 |
*/ |
| 254 |
|
| 255 |
proc ProcessCurLine () |
| 256 |
{ |
| 257 |
set(f, 0) /* f holds the line parent of the current person */ |
| 258 |
set(k, pop(CurK)) |
| 259 |
while (k) { |
| 260 |
set(p, indi(k)) |
| 261 |
set(g, pop(CurG)) |
| 262 |
set(r, pop(CurR)) |
| 263 |
call AddToAncTable(k, g, r, f) |
| 264 |
/*name(p) " (" d(g) ", " d(r) ") "/*DEBUG*/ |
| 265 |
set(f, k) |
| 266 |
set(k, pop(CurK)) |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
/* |
| 271 |
* AddToAncTable - This routine adds information to the ancestor table. |
| 272 |
* Each table entry is a list with six elements: |
| 273 |
* 1 Key of person |
| 274 |
* 2 ID of person |
| 275 |
* 3 Number of appearances in pedigree |
| 276 |
* 4 List of generations relative to key person by appearance |
| 277 |
* 5 List of relationships to key person by appearance |
| 278 |
* 6 List of children of this person who are also ancestors of key person |
| 279 |
*/ |
| 280 |
|
| 281 |
proc AddToAncTable (k, g, r, f) |
| 282 |
{ |
| 283 |
if (e, lookup(AncT, k)) { /* if person is already in table ... */ |
| 284 |
|
| 285 |
setel(e, 3, add(1, getel(e, 3))) /* incr num of appearances */ |
| 286 |
set(l, getel(e, 4)) |
| 287 |
enqueue(l, g) /* update list of generations */ |
| 288 |
set(l, getel(e, 5)) |
| 289 |
enqueue(l, r) /* update list of relationships */ |
| 290 |
|
| 291 |
} else { /* this is the first time this ancestor has been seen */ |
| 292 |
|
| 293 |
list(e) /* create new, empty table entry for person */ |
| 294 |
enqueue(e, k) /* add person's key */ |
| 295 |
enqueue(e, 0) /* init id to zero */ |
| 296 |
enqueue(e, 1) /* init num of appearences to one */ |
| 297 |
list(l) /* create sub-list to hold generations */ |
| 298 |
enqueue(l, g) /* init sub-list to current generation */ |
| 299 |
enqueue(e, l) /* add sub-list to table entry */ |
| 300 |
list(l) /* create sub-list to hold relationships */ |
| 301 |
enqueue(l, r) /* init sub-list to current relationship */ |
| 302 |
enqueue(e, l) /* add sub-list to table entry */ |
| 303 |
list(l) /* create sub-list to hold line descendants */ |
| 304 |
enqueue(e, l) /* add (empty) sub-list to table entry */ |
| 305 |
insert(AncT, k, e) /* add new entry to ancestor table */ |
| 306 |
enqueue(AncL, k) /* add key of person to ancestor list */ |
| 307 |
} |
| 308 |
if (f) { /* if not top of line make a child of line parent */ |
| 309 |
set(d, lookup(AncT, f)) |
| 310 |
set(l, getel(d, 6)) |
| 311 |
if (not(inlist(l, k))) { |
| 312 |
enqueue (l, k) |
| 313 |
} |
| 314 |
} |
| 315 |
} |
| 316 |
|
| 317 |
/* |
| 318 |
* NumberAncestors - This routine numbers the ancestors in the ancestor |
| 319 |
* table. |
| 320 |
*/ |
| 321 |
|
| 322 |
proc NumberAncestors () |
| 323 |
{ |
| 324 |
forlist(BOLK, k, n) { |
| 325 |
set(p, indi(k)) |
| 326 |
while (f, LineParent(p)) { set(p, f) } |
| 327 |
call NumberLine(key(p)) |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
proc NumberLine (k) |
| 332 |
{ |
| 333 |
set(e, lookup(AncT, k)) |
| 334 |
if (ne(0, getel(e, 2))) { return() } |
| 335 |
list(TmpQ) |
| 336 |
enqueue(TmpQ, k) |
| 337 |
while (k, dequeue(TmpQ)) { |
| 338 |
set(p, indi(k)) |
| 339 |
set(e, lookup(AncT, k)) |
| 340 |
setel(e, 2, CurID) |
| 341 |
set(CurID, add(1, CurID)) |
| 342 |
set(cl, getel(e, 6)) |
| 343 |
families (p, f, s, n) { |
| 344 |
children (f, o, m) { |
| 345 |
if (inlist(cl, key(o))) { |
| 346 |
enqueue(TmpQ, savekey(key(o))) |
| 347 |
} |
| 348 |
} |
| 349 |
} |
| 350 |
} |
| 351 |
} |
| 352 |
|
| 353 |
proc CreateTOLList () |
| 354 |
{ |
| 355 |
table(TOLT) list(TOLL) |
| 356 |
forlist (BOLK, k, n) { |
| 357 |
set(p, indi(k)) |
| 358 |
while (f, LineParent(p)) { set(p, f) } |
| 359 |
set(s, savekey(key(p))) |
| 360 |
if (and(nestr(k, s), not(lookup(TOLT, s)))) { |
| 361 |
enqueue(TOLL, s) |
| 362 |
insert(TOLT, s, s) |
| 363 |
} |
| 364 |
} |
| 365 |
} |
| 366 |
|
| 367 |
proc ShowTOLList () |
| 368 |
{ |
| 369 |
"START OF LINE LIST --\n" |
| 370 |
forlist (TOLL, k, n) { |
| 371 |
name(indi(k)) "\n" |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
/* |
| 376 |
* WriteReport - This routine controls writing a report. Right now this |
| 377 |
* program has built in knowledge that the report is being generated in |
| 378 |
* nroff format. This should be changed so that only generic routines |
| 379 |
* are called out of this routine, making substitution for different report |
| 380 |
* formats (e.g., LaTeX, HTML) easier in the future. |
| 381 |
*/ |
| 382 |
|
| 383 |
proc WriteReport () |
| 384 |
{ |
| 385 |
call WriteHeading() |
| 386 |
table(FamT) |
| 387 |
forlist (TOLL, k, n) { |
| 388 |
call WriteLine(k) |
| 389 |
} |
| 390 |
call WriteTail() |
| 391 |
} |
| 392 |
|
| 393 |
/* |
| 394 |
* WriteLine - This routine is responsible writing a single line to the |
| 395 |
* report file. |
| 396 |
*/ |
| 397 |
|
| 398 |
proc WriteLine (k) /* k -- key of a line's top of line person */ |
| 399 |
{ |
| 400 |
call LineTitle(k) |
| 401 |
set(e, lookup(AncT, k)) |
| 402 |
list(TmpQ) |
| 403 |
enqueue(TmpQ, k) |
| 404 |
while (k, dequeue(TmpQ)) { |
| 405 |
set(e, lookup(AncT, k)) |
| 406 |
call WriteLinePerson(e) |
| 407 |
call WriteChildren(e) |
| 408 |
forlist(getel(e, 6), c, n) { |
| 409 |
enqueue(TmpQ, c) |
| 410 |
} |
| 411 |
} |
| 412 |
} |
| 413 |
|
| 414 |
proc EmitPara () { |
| 415 |
if (eq(format_type, 0)) { call nroffPara() } |
| 416 |
else { call sgmlPara() } |
| 417 |
} |
| 418 |
|
| 419 |
proc EmitLeftSquareBracket () { |
| 420 |
if (eq(format_type, 0)) { call nroffLeftSquareBracket() } |
| 421 |
else { call sgmlLeftSquareBracket() } |
| 422 |
} |
| 423 |
|
| 424 |
proc EmitRightSquareBracket () { |
| 425 |
if (eq(format_type, 0)) { call nroffRightSquareBracket() } |
| 426 |
else { call sgmlRightSquareBracket() } |
| 427 |
} |
| 428 |
|
| 429 |
proc EmitStartList () { |
| 430 |
if (eq(format_type, 0)) { call nroffStartList() } |
| 431 |
else { call sgmlStartList() } |
| 432 |
} |
| 433 |
|
| 434 |
proc EmitEndList () { |
| 435 |
if (eq(format_type, 0)) { call nroffEndList() } |
| 436 |
else { call sgmlEndList() } |
| 437 |
} |
| 438 |
|
| 439 |
proc EmitChildItem () { |
| 440 |
if (eq(format_type, 0)) { call nroffChildItem() } |
| 441 |
else { call sgmlChildItem() } |
| 442 |
} |
| 443 |
|
| 444 |
proc WriteHeading () { |
| 445 |
if (eq(format_type, 0)) { call nroffhead() } |
| 446 |
else { call sgmlhead() } |
| 447 |
} |
| 448 |
|
| 449 |
proc WriteTail () { |
| 450 |
if (eq(format_type, 0)) { call nrofftail() } |
| 451 |
else { call sgmltail() } |
| 452 |
} |
| 453 |
|
| 454 |
proc LineTitle (k) |
| 455 |
{ |
| 456 |
if (eq(format_type, 0)) { call nroffLineTitle(k) } |
| 457 |
else { call sgmlLineTitle(k) } |
| 458 |
} |
| 459 |
|
| 460 |
proc nroffhead () |
| 461 |
{ |
| 462 |
".de CH\n" |
| 463 |
".sp\n" |
| 464 |
".in 11n\n" |
| 465 |
".ti 1\n" |
| 466 |
"\\h'3n'\\h'-\\w'\\\\$1'u'\\\\$1\\h'5n'\\h'-\\w'\\\\$2'u'\\\\$2\\h'1n'\n" |
| 467 |
"..\n" |
| 468 |
|
| 469 |
".de P\n.sp\n.in 0\n..\n" |
| 470 |
/*".po 5\n"*/ |
| 471 |
".ll 72\n" |
| 472 |
".ls 1\n" |
| 473 |
".na\n" |
| 474 |
} |
| 475 |
|
| 476 |
proc sgmlhead () |
| 477 |
{ |
| 478 |
|
| 479 |
"<!doctype linuxdoc system>" nl() |
| 480 |
"<article>" nl() |
| 481 |
"<title>All Lines</title>" nl() |
| 482 |
"<author>by Marc Nozell</author>" |
| 483 |
"<abstract> " nl() |
| 484 |
"This shows all ancestral lines of a specified person using a pseudo-Register format." |
| 485 |
"</abstract>" nl() |
| 486 |
"<toc>" nl() |
| 487 |
} |
| 488 |
|
| 489 |
proc nrofftail () |
| 490 |
{ |
| 491 |
" " nl() /* pretty boring... */ |
| 492 |
} |
| 493 |
|
| 494 |
proc sgmltail () |
| 495 |
{ |
| 496 |
" </article>" nl() |
| 497 |
} |
| 498 |
|
| 499 |
proc nroffLineTitle (k) { |
| 500 |
".P\n.sp 2\nANCESTRAL LINE FROM " upper(name(indi(k))) "\n" |
| 501 |
".br\n-----------------------------------------------------\n" |
| 502 |
} |
| 503 |
|
| 504 |
proc sgmlLineTitle (k) { |
| 505 |
nl()"<sect>Ancestral line from " upper(name(indi(k))) "\n" |
| 506 |
} |
| 507 |
|
| 508 |
proc nroffPara () { |
| 509 |
".P\n" |
| 510 |
} |
| 511 |
|
| 512 |
proc sgmlPara () { |
| 513 |
"<p>\n" |
| 514 |
} |
| 515 |
|
| 516 |
proc nroffLeftSquareBracket () { |
| 517 |
"[" |
| 518 |
} |
| 519 |
proc sgmlLeftSquareBracket () { |
| 520 |
"[" |
| 521 |
} |
| 522 |
|
| 523 |
proc nroffRightSquareBracket () { |
| 524 |
"]" |
| 525 |
} |
| 526 |
proc sgmlRightSquareBracket () { |
| 527 |
"]" |
| 528 |
} |
| 529 |
|
| 530 |
proc nroffStartList () { |
| 531 |
"\n" |
| 532 |
} |
| 533 |
|
| 534 |
proc sgmlStartList () { |
| 535 |
"<enum>\n" |
| 536 |
} |
| 537 |
|
| 538 |
proc nroffEndList () { |
| 539 |
"\n" |
| 540 |
} |
| 541 |
|
| 542 |
proc sgmlEndList () { |
| 543 |
"</enum>\n" |
| 544 |
} |
| 545 |
|
| 546 |
proc nroffChildItem () { |
| 547 |
" " |
| 548 |
} |
| 549 |
|
| 550 |
proc sgmlChildItem () { |
| 551 |
"<item>\n" |
| 552 |
} |
| 553 |
|
| 554 |
|
| 555 |
/* |
| 556 |
* WriteChildren - This routine writes out the children for a person in an |
| 557 |
* ancestral line. |
| 558 |
*/ |
| 559 |
|
| 560 |
proc WriteChildren (e) |
| 561 |
{ |
| 562 |
set(p, indi(getel(e, 1))) |
| 563 |
set(cl, getel(e, 6)) /* list of child keys also in this line */ |
| 564 |
families (p, f, s, n) { |
| 565 |
if (s) { set(u, save(name(s))) } |
| 566 |
else { set(u, "(_____)") } |
| 567 |
if (lookup(FamT, key(f))) { |
| 568 |
call EmitPara() |
| 569 |
"Children of " name(p) " and " u |
| 570 |
" listed under " u ".\n" |
| 571 |
} elsif (gt(nchildren(f), 0)) { |
| 572 |
call EmitPara() |
| 573 |
"Children of " name(p) " and " u ":\n" |
| 574 |
call EmitStartList() |
| 575 |
children(f, c, m) { |
| 576 |
if (inlist(cl, key(c))) { |
| 577 |
set(ce, lookup(AncT, key(c))) |
| 578 |
call EmitChildItem() |
| 579 |
d(getel(ce, 2)) " " |
| 580 |
roman(m) "\n" |
| 581 |
call shortvitals(c) |
| 582 |
} else { |
| 583 |
call EmitChildItem() |
| 584 |
roman(m) "\n" |
| 585 |
call middlevitals(c) |
| 586 |
} |
| 587 |
} |
| 588 |
insert(FamT, savekey(key(f)), 1) |
| 589 |
call EmitEndList() |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
|
| 594 |
proc shortvitals (i) |
| 595 |
{ |
| 596 |
name(i) |
| 597 |
set(b, birth(i)) set(d, death(i)) |
| 598 |
if (and(b, short(b))) { ", b. " short(b) } |
| 599 |
if (and(d, short(d))) { ", d. " short(d) } |
| 600 |
".\n" |
| 601 |
call EmitPara() |
| 602 |
} |
| 603 |
|
| 604 |
proc middlevitals (i) |
| 605 |
{ |
| 606 |
name(i) ".\n" |
| 607 |
set(e, birth(i)) |
| 608 |
if(and(e,long(e))) { |
| 609 |
call EmitPara() |
| 610 |
"Born " long(e) ".\n" } |
| 611 |
if (eq(1, nspouses(i))) { |
| 612 |
spouses(i, s, f, n) { |
| 613 |
call EmitPara() |
| 614 |
"Married" |
| 615 |
call spousevitals(s, f) |
| 616 |
} |
| 617 |
} else { |
| 618 |
spouses(i, s, f, n) { |
| 619 |
call EmitPara() |
| 620 |
"Married " ord(n) "," |
| 621 |
call spousevitals(s, f) |
| 622 |
} |
| 623 |
} |
| 624 |
set(e, death(i)) |
| 625 |
if(and(e, long(e))) { |
| 626 |
call EmitPara() |
| 627 |
"Died " long(e) ".\n" } |
| 628 |
set(p, 0) |
| 629 |
} |
| 630 |
|
| 631 |
/* |
| 632 |
* WriteLinePerson - This routine generates the report output for one |
| 633 |
* person in one of the ancestral lines. This version of the routine |
| 634 |
* generates output in nroff format. It prints boiler plate vitals |
| 635 |
* information about the person followed by all notes in the person's |
| 636 |
* record in the database. This routine does not print the person's |
| 637 |
* children (see routine >>>>> for this). |
| 638 |
*/ |
| 639 |
|
| 640 |
proc WriteLinePerson (e) |
| 641 |
{ |
| 642 |
set(p, indi(getel(e, 1))) |
| 643 |
call EmitPara() |
| 644 |
d(getel(e, 2)) " " |
| 645 |
name(p) |
| 646 |
if (ORel) { |
| 647 |
call EmitLeftSquareBracket() |
| 648 |
set(c, "") |
| 649 |
forlist (getel(e, 5), r, n) { |
| 650 |
c call ShowRel(r) set(c, ", ") |
| 651 |
} |
| 652 |
call EmitRightSquareBracket() |
| 653 |
} |
| 654 |
".\n" |
| 655 |
call EmitPara() |
| 656 |
set(o, birth(p)) |
| 657 |
if(and(o, long(o))) { "Born " long(o) ".\n" } |
| 658 |
if (eq(1, nspouses(p))) { |
| 659 |
spouses(p, s, f, n) { |
| 660 |
"Married" |
| 661 |
call spousevitals(s, f) |
| 662 |
} |
| 663 |
} else { |
| 664 |
spouses(p, s, f, n) { |
| 665 |
"Married " ord(n) "," |
| 666 |
call spousevitals(s, f) |
| 667 |
} |
| 668 |
} |
| 669 |
set(o, death(p)) |
| 670 |
if(and(o, long(o))) { "Died " long(o) ".\n" } |
| 671 |
set(b, 0) |
| 672 |
fornotes(root(p), n) { |
| 673 |
if (not(b)) { |
| 674 |
call EmitPara() |
| 675 |
set(b, 1) } |
| 676 |
n "\n" |
| 677 |
} |
| 678 |
} |
| 679 |
|
| 680 |
proc spousevitals (s, f) |
| 681 |
{ |
| 682 |
set(e, marriage(f)) |
| 683 |
if (and(e, long(e))) { "\n" long(e) "," } |
| 684 |
"\n" name(s) |
| 685 |
set(e, birth(s)) |
| 686 |
if (and(e, long(e))) { ",\nborn " long(e) } |
| 687 |
set(e, death(s)) |
| 688 |
if (and(e, long(e))) { ",\ndied " long(e) } |
| 689 |
set(d, LineParent(s)) |
| 690 |
set(m, OthrParent(s)) |
| 691 |
if (or(d, m)) { |
| 692 |
",\n" |
| 693 |
if (male(s)) { "son of " } |
| 694 |
elsif (female(s)) { "daughter of " } |
| 695 |
else { "child of " } |
| 696 |
} |
| 697 |
if (d) { name(d) } |
| 698 |
if (and(d, m)) { "\nand " } |
| 699 |
if (m) { name(m) } |
| 700 |
".\n" |
| 701 |
} |
| 702 |
|
| 703 |
/* |
| 704 |
* ShowBOLLists - This debug routine shows the bottom of line persons as |
| 705 |
* recorded in the BOLK, BOLG, and BOLR lists |
| 706 |
*/ |
| 707 |
|
| 708 |
proc ShowBOLLists () |
| 709 |
{ |
| 710 |
forlist(BOLK, k, n) { |
| 711 |
set(g, getel(BOLG, n)) set(r, getel(BOLR, n)) |
| 712 |
name(indi(k)) " " d(g) " " |
| 713 |
d(r) " (" call ShowRel(r) ")\n" |
| 714 |
} |
| 715 |
} |
| 716 |
|
| 717 |
proc ShowCurLine () |
| 718 |
{ |
| 719 |
set(k, pop(CurK)) |
| 720 |
set(p, indi(k)) |
| 721 |
while (p) { |
| 722 |
set(g, pop(CurG)) set(r, pop(CurR)) |
| 723 |
name(p) " (" d(g) "," d(r) ") " |
| 724 |
set(k, pop(CurK)) set(p, indi(k)) |
| 725 |
} |
| 726 |
"\n" |
| 727 |
} |
| 728 |
|
| 729 |
/* ShowAncTable -- Debug routine which shows contents of AncT. */ |
| 730 |
|
| 731 |
proc ShowAncTable () |
| 732 |
{ |
| 733 |
forlist(AncL, k, n) { |
| 734 |
set(e, lookup(AncT, k)) |
| 735 |
set(p, indi(k)) |
| 736 |
set(i, getel(e, 2)) |
| 737 |
set(g, getel(e, 4)) |
| 738 |
set(r, getel(e, 5)) |
| 739 |
set(d, getel(e, 6)) |
| 740 |
k " " name(p) " " d(i) " " |
| 741 |
forlist (g, j, l) { d(getel(g, l)) " " } |
| 742 |
forlist (r, j, l) { call ShowRel(getel(r, l)) " " } |
| 743 |
forlist (d, c, l) { name(indi(c)) " " } |
| 744 |
"\n" |
| 745 |
} |
| 746 |
} |
| 747 |
|
| 748 |
proc ShowRel (r) |
| 749 |
{ |
| 750 |
if (eq(r, 1)) { "s" } |
| 751 |
if (gt(r, 1)) { |
| 752 |
list(RelStack) |
| 753 |
push(RelStack, neg(1)) |
| 754 |
while (gt(r, 1)) { |
| 755 |
set(m, mod(r, 2)) |
| 756 |
set(r, div(r, 2)) |
| 757 |
push(RelStack, m) |
| 758 |
} |
| 759 |
set(r, pop(RelStack)) |
| 760 |
while (ne(r, neg(1))) { |
| 761 |
if (r) { "m" } |
| 762 |
else { "f" } |
| 763 |
set(r, pop(RelStack)) |
| 764 |
} |
| 765 |
} |
| 766 |
} |
| 767 |
|
| 768 |
/* inlist -- See if a string is in a list of strings */ |
| 769 |
|
| 770 |
func inlist (l, s) |
| 771 |
{ |
| 772 |
forlist(l, e, n) { |
| 773 |
if (eqstr(e, s)) { return(1) } |
| 774 |
} |
| 775 |
return(0) |
| 776 |
} |
| 777 |
|
| 778 |
func savekey (k) |
| 779 |
{ |
| 780 |
if (e, lookup(KeyT, k)) { return(e) } |
| 781 |
set(k, save(k)) |
| 782 |
insert(KeyT, k, k) |
| 783 |
return(k) |
| 784 |
} |