| 1 |
/* |
| 2 |
* @progname relink.ll |
| 3 |
* @version 1995-06 |
| 4 |
* @author J.F. Chandler |
| 5 |
* @category |
| 6 |
* @output GEDCOM |
| 7 |
* @description |
| 8 |
|
| 9 |
LifeLines program to reconstruct pointers from persons to families when |
| 10 |
these pointers are missing, but can be deduced from the corresponding |
| 11 |
pointers from families to persons. Do this only for persons with no |
| 12 |
pointers to families at all. Similarly, reconstruct pointers from |
| 13 |
families to persons where necessary. |
| 14 |
|
| 15 |
The output is a GEDCOM file which includes only the individual and family |
| 16 |
records from the database. Other record types must be recovered separately |
| 17 |
because there is no iterator in the language for those record types. |
| 18 |
|
| 19 |
relink - J.F. Chandler - 1995 Jun |
| 20 |
*/ |
| 21 |
|
| 22 |
proc main() { |
| 23 |
"0 HEAD\n1 SOUR RELINK\n1 DEST ANY\n" |
| 24 |
forindi(i,n) { |
| 25 |
traverse(inode(i),node,level) { |
| 26 |
d(level) " " |
| 27 |
if(eq(level,0)) { "@" key(i) "@ " } |
| 28 |
tag(node) |
| 29 |
if(v,value(node)) { " " v } |
| 30 |
nl() |
| 31 |
} |
| 32 |
if(not(or(nfamilies(i),parents(i)))) { |
| 33 |
set(indk,save(key(i))) |
| 34 |
forfam(f,k) { |
| 35 |
if(or(eq(0,strcmp(indk,key(wife(f)))), |
| 36 |
eq(0,strcmp(indk,key(husband(f)))))) { |
| 37 |
"1 FAMS @" key(f) "@\n" |
| 38 |
} elsif(nchildren(f)) { |
| 39 |
children(f,child,l) { |
| 40 |
if(eq(0,strcmp(indk,key(child)))) { |
| 41 |
"1 FAMC @" key(f) "@\n" |
| 42 |
break() |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
forfam(f,k) { |
| 50 |
traverse(fnode(f),node,level) { |
| 51 |
d(level) " " |
| 52 |
if(eq(level,0)) { "@" key(f) "@ " } |
| 53 |
tag(node) |
| 54 |
if(v,value(node)) { " " v } |
| 55 |
nl() |
| 56 |
} |
| 57 |
if(not(or(husband(f),wife(f),nchildren(f)))) { |
| 58 |
set(famk,save(key(f))) |
| 59 |
forindi(i,n) { |
| 60 |
families(i,fam,spo,l) { |
| 61 |
if(eq(0,strcmp(famk,key(fam)))) { |
| 62 |
if(male(i)) {"1 HUSB @" key(i) "@\n"} |
| 63 |
else {"1 WIFE @" key(i) "@\n"} |
| 64 |
break() |
| 65 |
} |
| 66 |
} |
| 67 |
if(eq(0,strcmp(famk,key(parents(i))))) { |
| 68 |
"1 CHIL @" key(i) "@\n" |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
} |
| 73 |
"0 TRLR\n" |
| 74 |
} |