| 1 |
/* |
| 2 |
* @progname anc2_ged.ll |
| 3 |
* @version 1.0 |
| 4 |
* @author Dennis Nicklaus |
| 5 |
* @category |
| 6 |
* @output GedCom |
| 7 |
* @description |
| 8 |
* make a gedcom file of the ancestors of a set of individuals |
| 9 |
* |
| 10 |
*/ |
| 11 |
proc main () |
| 12 |
{ |
| 13 |
indiset(a) |
| 14 |
monthformat(4) |
| 15 |
indiset(b) |
| 16 |
getindi(i) |
| 17 |
|
| 18 |
while (i){ |
| 19 |
addtoset(a, i, 0) |
| 20 |
set(i,0) |
| 21 |
getindimsg(i,"Enter next person to output GEDCOM ancestors of") |
| 22 |
} |
| 23 |
set(b,ancestorset(a)) |
| 24 |
set(b,union(b,a)) |
| 25 |
|
| 26 |
call print_header() |
| 27 |
gengedcom(b) |
| 28 |
call sour_init() |
| 29 |
call sour_addset(b) |
| 30 |
call sour_ged() |
| 31 |
|
| 32 |
"0 TRLR\n" |
| 33 |
|
| 34 |
} |
| 35 |
|
| 36 |
proc print_header() |
| 37 |
{ |
| 38 |
"0 HEAD\n" |
| 39 |
"1 SOUR Lifelines\n" |
| 40 |
"1 DATE " stddate(gettoday()) nl() |
| 41 |
"0 @SM1@ SUBM\n" |
| 42 |
"1 NAME " getproperty("user.fullname") "\n" |
| 43 |
"1 ADDR " getproperty("user.address") "\n" |
| 44 |
"2 CONT " getproperty("user.email") "\n" |
| 45 |
} |
| 46 |
global(sour_list) |
| 47 |
global(sour_table) |
| 48 |
|
| 49 |
proc sour_init() |
| 50 |
{ |
| 51 |
table(sour_table) |
| 52 |
list(sour_list) |
| 53 |
} |
| 54 |
/* sour_addind() adds the sources referenced for this individual */ |
| 55 |
|
| 56 |
proc sour_addind(i) |
| 57 |
{ |
| 58 |
traverse(root(i), m, l) { |
| 59 |
if (nestr("SOUR", tag(m))) { continue() } |
| 60 |
set(v, value(m)) |
| 61 |
if (eqstr("", v)) { continue() } |
| 62 |
if(reference(v)) { |
| 63 |
if (ne(0, lookup(sour_table, v))) { continue() } |
| 64 |
set(v, save(v)) |
| 65 |
insert(sour_table, v, 1) |
| 66 |
enqueue(sour_list, v) |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
proc sour_addset(s) |
| 72 |
{ |
| 73 |
forindiset (s, i, a, n) { |
| 74 |
call sour_addind(i) |
| 75 |
families(i, f, sp, m) { |
| 76 |
call sour_addind(f) |
| 77 |
} |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
/* sour_ged() outputs the current source list in GEDCOM format */ |
| 82 |
|
| 83 |
proc sour_ged() |
| 84 |
{ |
| 85 |
table(other_table) |
| 86 |
list(other_list) |
| 87 |
|
| 88 |
forlist(sour_list, k, n) { |
| 89 |
set(r, dereference(k)) |
| 90 |
traverse(r, s, l) { |
| 91 |
d(l) |
| 92 |
if (xref(s)) { " " xref(s) } |
| 93 |
" " tag(s) |
| 94 |
if (v, value(s)) { |
| 95 |
" " v |
| 96 |
if(reference(v)) { |
| 97 |
if (ne(0, lookup(other_table, v))) { continue() } |
| 98 |
if (ne(0, lookup(sour_table, v))) { continue() } |
| 99 |
set(v, save(v)) |
| 100 |
insert(other_table, v, 1) |
| 101 |
enqueue(other_list, v) |
| 102 |
} |
| 103 |
} |
| 104 |
"\n" |
| 105 |
} |
| 106 |
} |
| 107 |
forlist(other_list, k, n) { |
| 108 |
set(r, dereference(k)) |
| 109 |
traverse(r, s, l) { |
| 110 |
d(l) |
| 111 |
if (xref(s)) { " " xref(s) } |
| 112 |
" " tag(s) |
| 113 |
if (v, value(s)) { " " v } |
| 114 |
"\n" |
| 115 |
} |
| 116 |
} |
| 117 |
} |