| 1 |
/* |
| 2 |
* @progname drep2.ll |
| 3 |
* @version 2.1 |
| 4 |
* @author Robert Simms |
| 5 |
* @category |
| 6 |
* @output Text |
| 7 |
* @description |
| 8 |
|
| 9 |
Produces an indented report on an individual's families and all |
| 10 |
descendant families. Details on individuals include NOTE lines, once. |
| 11 |
Line wrapping is done with indention maintained. |
| 12 |
|
| 13 |
At the beginning of main() is provided the means to easily change |
| 14 |
page width, tab size, and left margin. |
| 15 |
|
| 16 |
Written by: Robert Simms, 16 Feb 2000 |
| 17 |
[email protected], http://www.math.clemson.edu/~rsimms |
| 18 |
This is based on indiv3.ll, also by Robert Simms. |
| 19 |
|
| 20 |
Version 2.1: 30 May 2001, fixed the concatenation of multiple notes |
| 21 |
so that two spaces are inserted before every note after |
| 22 |
the first. Thanks to M.W. Poirier for pointing this out. |
| 23 |
______________ |
| 24 |
TODO: Clean up trailing spaces in output. |
| 25 |
|
| 26 |
*/ |
| 27 |
|
| 28 |
global(page_width) |
| 29 |
global(tab_size) |
| 30 |
global(left_margin) |
| 31 |
global(gen) |
| 32 |
global(genlim) |
| 33 |
global(iparent) |
| 34 |
global(ichild) |
| 35 |
|
| 36 |
proc main() { |
| 37 |
set(page_width, 72) |
| 38 |
set(tab_size, 3) |
| 39 |
set(left_margin, 1) |
| 40 |
|
| 41 |
getindi(person) |
| 42 |
getintmsg (genlim, "Maximum number of generations") |
| 43 |
report(person, genlim) |
| 44 |
|
| 45 |
/* NOTE: this footer may need modifying if the page_width is changed */ |
| 46 |
concat(" ______________________________ This report was produced on ", |
| 47 |
stddate(gettoday()), " _______", nl()) |
| 48 |
} |
| 49 |
|
| 50 |
func report(person, genlim) { |
| 51 |
list(toPrint) |
| 52 |
list(toScan) |
| 53 |
set(gen, 1) |
| 54 |
set(iparent, 1) |
| 55 |
set(ichild, 2) |
| 56 |
enqueue(toPrint, person) |
| 57 |
while( and( le(gen,genlim), gt(length(toPrint), 0) ) ) { |
| 58 |
">> Generation " d(gen) nl() |
| 59 |
while(i1, dequeue(toPrint)) { |
| 60 |
nl() doFams(i1) nl() |
| 61 |
enqueue(toScan, i1) |
| 62 |
} |
| 63 |
while(i1, dequeue(toScan)) { |
| 64 |
families(i1, fp, sp, fn) { |
| 65 |
children(fp, i_x, n_x) { |
| 66 |
if(gt(nfamilies(i_x), 0)) { |
| 67 |
enqueue(toPrint, i_x) |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
set(gen, add(gen, 1)) |
| 73 |
if(gt(length(toPrint), 0)) { |
| 74 |
nl() |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
func doFams(indi) { |
| 80 |
set(x, 0) |
| 81 |
set(skip, left_margin) |
| 82 |
set(x, outfam(indi, skip, x)) |
| 83 |
} |
| 84 |
|
| 85 |
func outfam(indi, skip, x) { |
| 86 |
set(x, outpers(indi, skip, x, 1, 1)) |
| 87 |
if(gt(nfamilies(indi), 0)) { |
| 88 |
set(skip, add(skip, tab_size)) |
| 89 |
families(indi, fam, sp, num) { |
| 90 |
set(x, 0) |
| 91 |
set(x, outline(concat("Family #", d(num)), skip, x)) |
| 92 |
if(date(marriage(fam))) { |
| 93 |
set(s, concat(", ", date(marriage(fam)))) |
| 94 |
} |
| 95 |
if(nestr("", place(marriage(fam)))) { |
| 96 |
set(s, concat(s, ", ", place(marriage(fam)))) |
| 97 |
} |
| 98 |
set(x, outline(s, skip, x)) |
| 99 |
set(x, 0) |
| 100 |
set(skip, add(skip, tab_size)) |
| 101 |
set(x, outpers(sp, skip, x, 1, 0)) |
| 102 |
if(gt(nchildren(fam), 0)) { |
| 103 |
set(x, outline("Children", skip, x)) |
| 104 |
set(x, 0) |
| 105 |
set(skip, add(skip, tab_size)) |
| 106 |
children(fam, child, no) { |
| 107 |
set(x, outpers(child, skip, x, or(not(nfamilies(child)),eq(gen,genlim)), 0 )) |
| 108 |
} |
| 109 |
set(skip, sub(skip, tab_size)) |
| 110 |
} |
| 111 |
set(skip, sub(skip, tab_size)) |
| 112 |
} |
| 113 |
} |
| 114 |
return(x) |
| 115 |
} |
| 116 |
|
| 117 |
func outpers(indi, skip, x, note_flag, parent) { |
| 118 |
if(indi) { |
| 119 |
print(name(indi), nl()) |
| 120 |
set(x, 0) |
| 121 |
if(note_flag) { |
| 122 |
if(parent) { |
| 123 |
set(s, concat(d(iparent), ". ", name(indi))) |
| 124 |
set(iparent, add(iparent, 1)) |
| 125 |
} else { |
| 126 |
set(s, name(indi)) |
| 127 |
} |
| 128 |
} else { |
| 129 |
if(and(lt(gen,genlim), gt(nfamilies(indi), 0))) { |
| 130 |
set(s, concat(name(indi), " <",d(ichild),">" )) |
| 131 |
set(ichild, add(ichild, 1)) |
| 132 |
} else { |
| 133 |
set(s, name(indi)) |
| 134 |
} |
| 135 |
} |
| 136 |
set(x, outline(s, skip, x)) |
| 137 |
set(skip, add(skip, tab_size)) |
| 138 |
set(s, "") |
| 139 |
if(birth(indi)) { |
| 140 |
set(s, concat(", b. ", long(birth(indi)))) |
| 141 |
} |
| 142 |
if(death(indi)) { |
| 143 |
set(s, concat(s, ", d. ", long(death(indi)))) |
| 144 |
} |
| 145 |
if(burial(indi)) { |
| 146 |
set(s, concat(s, ", buried at ", place(burial(indi)))) |
| 147 |
} |
| 148 |
set(s, concat(s, ". ")) |
| 149 |
set(x, outline(s, skip, x)) |
| 150 |
if(note_flag) { |
| 151 |
set(s, "") |
| 152 |
set(note_separator, "") |
| 153 |
fornotes(inode(indi), note) { |
| 154 |
set(s, concat(s, note_separator, note)) |
| 155 |
set(note_separator, " ") |
| 156 |
} |
| 157 |
set(x, outtxt(s, skip, x)) |
| 158 |
set(skip, sub(skip, tab_size)) |
| 159 |
} |
| 160 |
} else { |
| 161 |
print("_____ _____", nl()) |
| 162 |
set(x, 0) |
| 163 |
set(x, outline("_____ _____", skip, x)) |
| 164 |
} |
| 165 |
set(x, 0) |
| 166 |
return(x) |
| 167 |
} |
| 168 |
|
| 169 |
func outtxt(txt, skip, x) { |
| 170 |
set(cr, index(txt, nl(), 1)) |
| 171 |
while(ne(cr, 0)) { |
| 172 |
set(txt, save(txt)) |
| 173 |
set(txt2, concat(substring(txt, 1, sub(cr, 1)), " ")) |
| 174 |
set(x, outline(txt2, skip, x)) |
| 175 |
set(txt, substring(txt, add(cr, 1), strlen(txt))) |
| 176 |
set(cr, index(txt, nl(), 1)) |
| 177 |
} |
| 178 |
if(gt(strlen(txt), 0)) { |
| 179 |
set(x, outline(txt, skip, x)) |
| 180 |
} |
| 181 |
return(x) |
| 182 |
} |
| 183 |
|
| 184 |
func outline(text, skip, x) { |
| 185 |
if(eq(x, 0)) { |
| 186 |
col(add(skip, 1)) |
| 187 |
set(x, skip) |
| 188 |
} |
| 189 |
set(max, sub(page_width, x)) |
| 190 |
if(gt(strlen(text), max)) { |
| 191 |
set(space, breakpoint(text, max)) |
| 192 |
if(eq(space, 0)) { |
| 193 |
if(eq(x, skip)) { |
| 194 |
set(text, strsave(text)) |
| 195 |
substring(text, 1, sub(max, 1)) "-" |
| 196 |
set(x, 0) |
| 197 |
set(text, substring(text, max, strlen(text))) |
| 198 |
set(x, outline(text, skip, x)) |
| 199 |
} else { |
| 200 |
set(x, 0) |
| 201 |
set(x, outline(text, skip, x)) |
| 202 |
} |
| 203 |
} else { /* space gt 0 */ |
| 204 |
set(text, strsave(text)) |
| 205 |
substring(text, 1, sub(space, 1)) |
| 206 |
set(x, 0) |
| 207 |
set(text, strsave(substring(text, add(space, 1), strlen(text)))) |
| 208 |
while(eqstr(" ", substring(text, 1, 1))) { /* strip leading spaces */ |
| 209 |
set(text, strsave(substring(text, 2, strlen(text)))) |
| 210 |
} |
| 211 |
set(x, outline(text, skip, x)) |
| 212 |
} |
| 213 |
} else { |
| 214 |
text |
| 215 |
set(x, add(x, strlen(text))) |
| 216 |
} |
| 217 |
return(x) |
| 218 |
} |
| 219 |
|
| 220 |
func breakpoint(text, max) { |
| 221 |
set(space, 0) |
| 222 |
set(occ, 1) |
| 223 |
set(next, index(text, " ", occ)) |
| 224 |
incr(occ) |
| 225 |
while ( and(le(next, add(max, 1)), ne (next, 0))) { |
| 226 |
set(space, next) |
| 227 |
set(next, index(text, " ", occ)) |
| 228 |
incr(occ) |
| 229 |
} |
| 230 |
return(space) |
| 231 |
} |