File: igi-search.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (200 lines) | stat: -rw-r--r-- 4,140 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
/*
 * @progname    igi-search.ll
 * @version     1.1
 * @author      Vincent Broman
 * @category
 * @output      Text
 * @description
 *
 *     prints out a list of people to look up in the IGI,
 *     those who are closely enough related, who fall in a time range,
 *     and whose temple work is not done.
 */

include( "ldsgedcom.li")

/* TODO: needs a sort and handling "OF" places */

/*
 * indvordsdone and marrordsdone test whether all the individual (Bap/End/Sch)
 * or marriage (Ssp) ordinances are recorded for this individual
 * in the database.
 */

func indvordsdone( indi) {
    return( and( ldsbaptism( indi),
		 ldsendowment( indi),
		 or( ldschildsealing( indi),
		     not( father( indi)))))
}

func marrordsdone( indi) {
    families( indi, f, sp, ctm) {
	if( not( ldsspousesealing( f))) { return( 0) }
    }
    return( 1)
}

/* return as a string the birth/christening year if known, else 0 */
func knownbirthyear( indi) {
    set( b, birth( indi))
    if( not( b)) { set( b, baptism( indi)) }
    if( b) {
	return( save( year( b)))
    }
    return( 0)
}

global( thisyear)

/* isdead tests whether this individual is known to be dead
 * or can be assumed dead by the rules for LDS temple work submission.
 */
func isdead( indi) {
    if( death( indi)) { return( 1) }
    if( burial( indi)) { return( 1) }
    if( by, knownbirthyear( indi)) {
	return( le( strtoint( by), sub( thisyear, 110)))
    }
    families( indi, f, sp, ctd) {
	if( m, marriage( f)) {
	    if( md, year( m)) {
		if( le( strtoint( md), sub( thisyear, 95))) {
		    return( 1)
		}
	    }
	}
    }
    return( 0)
}

/* return the set of people who are wide-sense ancestors
 * of the given individual, plus the children of these wide-sense ancestors,
 * where a wide-sense ancestor is either the given individual himself/herself
 * a parent or step-parent of a wide-sense ancestor.
 */
func interestingforebearsof( indi) {
    indiset( res)
    addtoset( res, indi, key( indi))

    set( pf, parents( indi))
    if( not( pf)) { return( res) }

    if( h, husband( pf)) {
	set( res, union( res, interestingforebearsof( h)))
	families( h, f, sp, ctf) {
	    if( sp) {
		set( res, union( res, interestingforebearsof( sp)))
	    }
	    children( f, ch, ctc) {
		addtoset( res, ch, key( ch))
	    }
	}
	set( hk, key( h))
    } else {
	set( hk, "")
    }
    if( w, wife( pf)) {
	families( w, f, sp, cth) {
	    /* add only husbands not the father */
	    if( and( sp, nestr( hk, key( sp)))) {
		set( res, union( res, interestingforebearsof( sp)))
	    } else {
		children( f, ch, ctcc) {
		    addtoset( res, ch, key( ch))
		}
	    }
	}
    }
    return( res)
}

proc igiord( e) {
    if( e) {
	if( v, value( e)) {
	    v
	} else {
	    if( ed, date( e)) {
		ed
	    } else {
		"           "
	    }
	    " "
	    if( et, ldstemple( e)) {
		et
	    } else {
		"     "
	    }

	}
    }
}

proc printigientry( indi) {
    if( n, name( indi)) {
	n "  "
    } else {
	"<nameless>  "
    }
    "("
    if( fa, father( indi)) {
	if( fn, name( fa)) {
	    fn
	}
    }
    "/"
    if( mo, mother( indi)) {
	if( mn, name( mo)) {
	    mn
	}
    }
    ")  " nl()
    if( b, birth( indi)) {
        sex( indi)
	"B " long( b)
	if( c, baptism( indi)) {
	    " and "
	    sex( indi)
	    "C " long( c)
	}
    } elsif( c, baptism( indi)) {
        sex( indi)
	"C " long( c)
    } else {
        sex( indi)
	" no B/C event  "
    }
    nl()
    set( ba, ldsbaptism( indi))
    set( en, ldsendowment( indi))
    set( cs, ldschildsealing( indi))
    if( or( ba, en, cs)) {
	call igiord( ba)
	"/"
	call igiord( en)
	"/"
	call igiord( cs)
	nl()
    }
    nl()
}

proc main() {
    set( thisyear, strtoint( year( gettoday())))

    getindi( i, "Who's ancestors should be checked for IGI entries?")
    getint( fby, "First birth year of interest?")
    getint( lby, "Last  birth year of interest?")
    forindiset( interestingforebearsof( i), ai, k, ctb) {
	if( by, knownbirthyear( ai)) {
	    set( iby, strtoint( by))
	    if( and( isdead( ai),
		     not( indvordsdone( ai)),
		     le( fby, iby),
		     le( iby, lby))) {
		by nl()
		call printigientry( ai)
	    }
	}
    }
}