File: pdesc.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 (144 lines) | stat: -rw-r--r-- 3,889 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
/*
 * @progname       pdesc.ll
 * @version        4.3
 * @author         Wetmore, Manis, Jones, Eggert, Simms
 * @category       
 * @output         Text
 * @description    
 *
 * Produces indented descendant list with line wrapping at 78 columns
 * (user-specifiable) while maintaining the indentation level. Enhancement
 * from version 2 is the addition of user-specified maximum number of
 * generations. Version 4 makes the page_width (not 1 less) the limit on
 * character a shift inplacement. Also eliminated an extra space at the
 * beginning of each line that was not controlled by a left_margin parameter.
 *
 *   Code by Tom Wetmore, ttw@cbnewsl.att.com
 *   With modifications by:  Cliff Manis
 *   With modifications by:  James P. Jones
 *   With modifications by:  Jim Eggert (unknown spouse bugfix)
 *   With modifications by:  Robert Simms (indented line wrap) Mar '96
 *                                        (max number of generations) Jun '97
 *                                        (line wrap cleaned up) 16 Feb 2000
 *   With modifications by:  Vincent Broman (header cleanup) 2003-02
 *
 *   This report works only with the LifeLines Genealogy program
 *
 *   version one of this report was written by Tom Wetmore, in 1990.
 *
 *   It will select and produce a descendant report for the person
 *   selected.   Children of each spouse are printed below that spouse.
 *
 *   Descendants report format, which print the date in long format.
 *
 *   Output is an ASCII file.
 */

global(page_size)
global(tab_size)
global(max_depth)
global(left_margin)

proc main () {
	set(page_size, 78)
	set(tab_size, 3)    /* extra indentation upon line-wrap */
	set(left_margin, 0)

	getindi(indi)
	getintmsg (max_depth, "Maximum number of generations")
	set(skip, left_margin)
	call pout(0, indi)

	"===============================================" nl()
}

proc pout(gen, indi) {
	set(skip, mul(4,gen))
	col(add(skip, 1))
	set(x, skip)
	set(s, concat(d(add(gen, 1)), "--"))
	s
	set(x, add(x, tab_size))
	set(skip, x)
	call outp(indi, skip, x)
	set(next, add(1, gen))
	families(indi,fam,sp,num) {
		set(skip, add(2,mul(4,gen)))
		col(add(skip, 1))
		set(x, skip)
		"sp-"
                /* Don't try to show a spouse name if none known */
                if (sp) {
                        set(x, add(x, 4))
                        set(skip, x)
                        call outp(sp, skip, x)
                } else {
                        "Unknown" nl()
                }
		if (lt(next,max_depth)) {
			children(fam, child, no) {
				call pout(next, child)
			}
		}
	}
}

proc outp(indi, skip, x) {
	set(s, concat(fullname(indi, 1, 1, 40),
		" (",
		long(birth(indi)),
		" - ",
		long(death(indi)),
		")"))
		set(x, outline(s, add(tab_size, skip), x))
		"\n"
}

func outline(text, skip, x) {
	if (eq(x, 0)) {
		col(add(skip, 1))
		set(x, skip)
	}
	set(max, sub(page_size, x))
	if (gt(strlen(text), max)) {
		set(space, breakit(text, max))
		if (eq(space, 0)) {
			if (eq(x, skip)) {
				set(text, strsave(text))
				substring(text, 1, sub(max, 1)) "-"
				set(x, 0)
				set(text, substring(text, max, strlen(text)))
				set(x, outline(text, skip, x))
			} else {
				set(x, 0)
				set(x, outline(text, skip, x))
			}
		} else {              /* space gt 0 */
			set(text, strsave(text))
			substring(text, 1, sub(space, 1))
			set(x, 0)
			set(text, strsave(substring(text, add(space, 1), strlen(text))))
			while(eqstr(" ", substring(text, 1, 1))) { /* strip leading spaces */
				set(text, strsave(substring(text, 2, strlen(text))))
			}
			set(x, outline(text, skip, x))
		}
	} else {
		text
		set(x, add(x, strlen(text)))
	}
	return(x)
}

func breakit(text, max) {
	set(space, 0)
	set(occ, 1)
	set(next, index(text, " ", occ))
	incr(occ)
	while ( and(le(next, add(max, 1)), ne (next, 0))) {
		set(space, next)
		set(next, index(text, " ", occ))
		incr(occ)
	}
	return(space)
}