9
Test a database for reciprocity of pointers between persons and families.
10
Report any failures, primarily the following:
12
Person Inn is a spouse/child in Fnn, but Fnn has no corresponding pointer.
13
Family Fnn has HUSB/WIFE/CHIL Inn, but Inn has no corresponding pointer.
15
Some failures are supposed to be impossible, but are covered here
18
Family Fnn has HUSB/WIFE/CHIL Inn, but Inn does not exist.
19
Family Fnn has a null HUSB/WIFE/CHIL line.
20
Person Inn is a spouse/child in Fnn, but Fnn does not exist.
21
Person Inn has a null FAMS/FAMC line.
23
Version 1.0 - 2003 Jul 2 - John F. Chandler
25
This program works only with LifeLines.
32
table(spou) /* each entry is the list of spouses in the keyed family */
33
table(chil) /* each entry is the list of children in the keyed family */
35
"Testing database " qt() database() qt() " for pointer reciprocity\n"
39
/* loop through persons and note all the families they belong to */
42
fornodes(root(i),node) {
44
if(eqstr(type,"FAMC")) {
45
call tally(type,"child",chil,node,k)
46
} elsif(eqstr(type,"FAMS")) {
47
call tally(type,"spouse",spou,node,k)
51
/* loop through families and compare the members against the list
52
compiled by scanning persons -- flag any mismatches */
55
set(cl,lookup(chil,id))
56
set(sl,lookup(spou,id))
57
fornodes(root(f),node) {
59
if(eqstr(type,"CHIL")) { call checkoff(type,cl,id,node) }
60
elsif(or(eqstr(type,"HUSB"),eqstr(type,"WIFE"))) {
61
call checkoff(type,sl,id,node)
64
/* any remaining list elements are errors */
66
while(k,dequeue(sl)) {
67
"\nPerson " k " is a spouse in " id
68
", but " id " has no corresponding pointer."
72
while(k,dequeue(cl)) {
73
"\nPerson " k " is a child in " id
74
", but " id " has no corresponding pointer."
78
"\n\nFinished after checking " d(pointers) " pointers.\n"
82
/* check a family member against the expected list.
83
anyone not on the list is an error.
84
remove each person from the list when found here. */
85
proc checkoff(type,list,id,node) {
87
if(eq(mod(pointers,500),0)) { print(".") }
89
set(key,substring(k,2,sub(strlen(k),1)))
91
set(count,length(list))
95
if(eqstr(c,key)) { set(count,-1) }
96
else { enqueue(list,c) }
100
"\nFamily " id " has " type " " key ", but " key
101
if(reference(k)) { " has no corresponding pointer." }
102
else { " does not exist." }
104
} else { "\nFamily " id " has a null " type " line." }
107
/* build a list of persons who belong to families */
108
proc tally(type,member,table,node,k) {
110
if(eq(mod(pointers,500),0)) { print(".") }
113
set(id,save(substring(id,2,sub(strlen(id),1))))
114
if(l,lookup(table,id)) { enqueue(l,k) }
121
"\nPerson " k " is a " member " in " id
122
", but " id " does not exist."
123
} else { "\nPerson " k " has a null " type " line." }