File: desc_html.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 (159 lines) | stat: -rw-r--r-- 4,495 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
/*
 * @progname       desc_html.ll
 * @version        1.4
 * @author         Dick Knowles, Scott McGee, anon
 * @category       
 * @output         HTML
 * @description

This program is designed to be used in a cgi based genweb site to produce
a descendant chart for a specified individual. It is based on the desc-tree
program by Dick Knowles as modified by Scott McGee. A line is printed for 
every spouse and child including name, database key number, birth, marriage, 
and death information.

@(#)desc_html.ll	1.4 10/4/95
*/

include("cgi_html.li")

global(MAXGENS)
global(MAXLINES)
global(linecount)
global(gens)
global(mainpre)
global(spousepre)
global(indentpre)

proc main () {
  call set_cgi_html_globals()

  set(MAXGENS,20)             /* make "all" gens max at 20 */
  set(MAXLINES,500)           /* set max report lines */
  set(linecount,0)            /* initialize linecount */
  set(nm," ")
  getindi(nm)                 /* get individual */

  set(gens, 3)

  dayformat(0)
  monthformat(4)
  dateformat(0)

  set(mainpre, "-")
  set(spousepre, " s-")
  set(indentpre, "  |")

  call do_chart_head(nm, "Descendant")
  "<PRE>\n"
  call dofam(nm,"",1,0)               /* start with first person */
  "</PRE>\n"
  call do_tail(nm)
}


/* startfam:
   If we haven't reached the maximum or specified generation count,
   call dofam for each child in this family.
   Otherwise, print a message line if there are further descendants
   at this point.
*/
proc startfam (fam,prefix,level,isstep) {
    if (le(level,gens)) {               /* if not at last generation */
        children (fam,child,num) {      /* for each child */
            call dofam (child,          /* call dofam */
                        concat(prefix, indentpre),
                        add(level,1),
                        isstep)
        }
    } else {                            /* don't do this generation */
        if (gt(nchildren(fam),0)) {     /* but if there are children, */
                                        /* issue message */
            prefix "  [[Further descendants here"
            if (eq(isstep,1)) {
                " (stepchildren)"
            }
            ".]]\n"
            incr(linecount)
        }
    }
}

/* dofam:
   Write out a person and check for spouses and children.
   Each spouse is written, then this routine is called
   recursively for each child.  An incremented level is passed along
   in case the user specified a limited number of generations
*/

proc dofam (nm,prefix,level,isstep) {
  set(pre,mainpre)
  call printpers(nm,concat(prefix,pre),0,0)  /* print this person */
  if (and(ge(linecount,MAXLINES),gt(nfamilies(nm),0))) {
    prefix "  [[Reached line count max."
    "  May be further descendants here."
    "]]\n"
  } else {
    families(nm, fam, spouse, num) {   /* do for each family */
      if (ne(spouse,null)) {         /* if there is a spouse */
        /* print spouse */
        call printpers(spouse,concat(prefix,spousepre),1,fam)
        if (and(ge(linecount,MAXLINES),gt(nchildren(fam),0))) {
          prefix "  [[Reached line count max."
          "  May be further descendants here."
          "]]\n"
        } else {
          families (spouse, spsfam, ospouse, num2) {
            /* for each of the spouse families*/
            if(eq(fam,spsfam)){  /* only non-step families */
              call startfam (spsfam,prefix,level,0)
            }
          } /*end spouse's families*/
        } /* end spouse not ge MAXLINES */
      } else {                    /* there is no spouse */
        call startfam (fam,prefix,level,0)
      } /*end else no spouse*/
    } /*end 'families'*/
  } /* end MAXLINES else */
} /*end 'proc dofam'*/


/* printpers:
   Write output line for one person.
   Include birth and death dates if known.
   For a spouse, include marriage date if known.
*/
proc printpers (nm, prefix, spouse, fam) {
  prefix 
  if(nfamilies(nm)){
    set(hasChildren, 0)
    families(nm, f, s, n){
      if(nchildren(f)){
        set(hasChildren, 1)
      }
    }
  }
  href(nm, "Descendant")
  if(e, birth(nm)) {
    "\t b. " stddate(birth(nm))
  }
  if(e, marriage(fam)) {
    "\t m. " stddate(e)
  }
  if(e, death(nm)) {
    "\t d. " stddate(death(nm))
  }
  "\n"
  incr(linecount)
} /* end proc printpers */


/*
   key_no_char:
     Return string key of individual or family, without
     leading 'I' or 'F'.
*/
proc key_no_char (nm) {
    set(k, key(nm))
    substring(k,2,strlen(k))
} /* end proc key_no_char */