File: maritalinfo.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 (74 lines) | stat: -rw-r--r-- 1,911 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
/*
* @progname       maritalinfo.ll
* @version        1.0 (2002-11-13)
* @author         Perry Rapp
* @category       sample
* @output         screen
* @description
*
*                 Simple example of looping through marital (& divorce) info
*/

/* get marital & divorce lists, and then display them */
proc main() {

  getfam(family)
  list(marriages)
  getmarriages(family, marriages)
  if (not(empty(marriages))) {
    print("Marital events:", nl())
    forlist (marriages, node, offset) {
      if (eq(tag(node), "ENGA")) {
        call event_out("Engagement: ", node)
      }
      if (eq(tag(node), "MARR")) {
        call event_out("Marriage: ", node)
      }
    }
  }
  list(divorces)
  getdivorces(family, divorces)
  if (not(empty(divorces))) {
    print("Divorce events:", nl())
    forlist (divorces, node, offset) {
      if (eq(tag(node), "ANUL")) {
        call event_out("Annulment: ",  node)
      }
      if (eq(tag(node), "DIV")) {
        call event_out("Divorce: ", node)
      }
      if (eq(tag(node), "DIVF")) {
        call event_out("DivorceFiling: ", node)
      }
    }
  }

}

/* send out event info with header, to screen right now */
proc event_out(hdr, event) {
  print(event_string(hdr, event), nl())
}

/* make a display string out of an event and a header */
func event_string(hdr, event) {
  set(outstr, concat(hdr, short(event)))
  return(outstr)
}

/* get list of all marital events in family */
func getmarriages(family, evlist) {
  fornodes (root(family), node) {
    if (eq(tag(node), "MARR")) { push(evlist, node) }
    if (eq(tag(node), "ENGA")) { push(evlist, node) }
  }
}

/* get list of all divorce-style events in family */
func getdivorces(family, evlist) {
  fornodes (root(family), node) {
    if (eq(tag(node), "ANUL")) { push(evlist, node) }
    if (eq(tag(node), "DIV")) { push(evlist, node) }
    if (eq(tag(node), "DIVF")) { push(evlist, node) }
  }
}