File: ldsgedcom.li

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 (121 lines) | stat: -rw-r--r-- 2,690 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
/*
 * @progname    ldsgedcom.li
 * @version     1.2 of 2004-07-03
 * @author      Vincent Broman (vpbroman@mstar2.net)
 * @category
 * @output      gedcom event and string function values
 * @description
 *
 *  Utility functions supporting LDS aspects of GeDCom data
 *  ldstemple( event) -> string,
 *  ldsspousesealing( fam) -> event,
 *  ldsbaptism( indi) -> event,
 *  ldsendowment( indi) -> event,
 *  ldschildsealing( indi) -> event
 *
 * I put equivalent functions in my C source, but this can be used everywhere.
 */

func ldstemple( ev) {
    fornodes( ev, childnode) {
	if( eqstr( tag( childnode), "TEMP")) {
	    return( save( value( childnode)))
	}
    }
    return( 0)
}

func ldsspousesealing( fam) {
    fornodes( root( fam), childnode) {
	if( eqstr( tag( childnode), "SLGS")) {
	    return( childnode)
	}
    }
    return( 0)
}

func ldsbaptism( indi) {
    fornodes( root( indi), childnode) {
	if( eqstr( tag( childnode), "BAPL")) {
	    return( childnode)
	}
    }
    return( 0)
}

func ldsendowment( indi) {
    fornodes( root( indi), childnode) {
	if( eqstr( tag( childnode), "ENDL")) {
	    return( childnode)
	}
    }
    return( 0)
}

/*
 * ldschildsealing(i) returns a SLGC sealing of child EVENT for the INDI indi
 * or if no such event is found zero is returned.
 * if the person is a child sealed in more than one family,
 * only the first find is returned.
 * This searches first the INDI-SLGC or INDI-FAMC-SLGC syntax, then the old FAM-CHIL-SLGC one.
 */

func ldschildsealing( indi) {
    fornodes( root( indi), childnode) {
	if( eqstr( tag( childnode), "FAMC")) {
	    fornodes( childnode, sealnode) {
		if( eqstr( tag( sealnode), "SLGC")) {
		    return( sealnode)
		}
	    }
	} else if( eqstr( tag( childnode), "SLGC")) {
		return( childnode)
	}
    }
    set( k, save( concat( "@", key( indi), "@")))
    if( p, parents( indi)) {
	/* children( p, ch, i) */
	fornodes( root( p), childnode) {
	    if( and( eqstr( tag( childnode), "CHIL"),
		     eqstr( value( childnode), k))) {
		fornodes( childnode, sealnode) {
		    if( eqstr( tag( sealnode), "SLGC")) {
			return( sealnode)
		    }
		}
	    }
	}
    }
    return( 0)
}

/* for testing
proc printordinance( ord) {
    if( ord) {
	tag( ord) ": "
	if( val, value( ord)) {
	    val
	} else {
	    set( ordd, save( date( ord)))
	    ordd
	    if( ordt, ldstemple( ord)) {
		if( ordd) { ", " }
		ordt
	    }
	}
	nl()
    }
}

proc main() {
    "All individual ordinances" nl() nl()
    forindi( i, c) {
	"#" d( c) ": " name( i)
	if( b, birth( i)) { "  b. " long( b) }
	nl()
	call printordinance( ldsbaptism( i))
	call printordinance( ldsendowment( i))
	call printordinance( ldschildsealing( i))
    }
}
 */