| 1 |
/* |
| 2 |
* @progname connect2.ll |
| 3 |
* @version 2.1 |
| 4 |
* @author Simms |
| 5 |
* @category |
| 6 |
* @output Text |
| 7 |
* @description |
| 8 |
* Describes the family line connecting an ancestor/descendant |
| 9 |
|
| 10 |
Written by: Robert Simms, 19 Sep 1997 |
| 11 |
[email protected], http://www.math.clemson.edu/~rsimms |
| 12 |
|
| 13 |
Asks for a descendant and an ancestor then produces, for the line |
| 14 |
connecting the two persons, |
| 15 |
an indented report on an individual and all families associated |
| 16 |
with that individual. Details on individuals include NOTE lines. |
| 17 |
Line wrapping is done with indenting maintained. |
| 18 |
|
| 19 |
This program does not check to make sure that the descendant given is really |
| 20 |
a descendant of the ancestor. An error will result if not. |
| 21 |
|
| 22 |
At the beginning of main() is provided the means to easily change page width, |
| 23 |
tab size, left margin, and whether or not to include notes in output. |
| 24 |
|
| 25 |
Revisions: 2: Robert Simms, 17 Feb 2000, made line-wrapping code more |
| 26 |
consistent in its use of the parameters page_width, |
| 27 |
and left_margin. |
| 28 |
2.1: Robert Simms, 30 May 2001, fixed the concatenation of |
| 29 |
multiple notes so that two spaces are inserted before |
| 30 |
every note after the first note. |
| 31 |
Thanks to M.W. Poirier for pointing this out. |
| 32 |
|
| 33 |
*/ |
| 34 |
|
| 35 |
global(page_width) |
| 36 |
global(tab_size) |
| 37 |
global(left_margin) |
| 38 |
global(note_flag) |
| 39 |
global(plist) |
| 40 |
|
| 41 |
proc main() { |
| 42 |
set(page_width, 80) |
| 43 |
set(tab_size, 3) |
| 44 |
set(left_margin, 0) |
| 45 |
set(note_flag, 1) /*set equal to 1 to include notes, 0 NOT to include notes*/ |
| 46 |
list(plist) |
| 47 |
|
| 48 |
|
| 49 |
getindi(indi1, "Descendant") |
| 50 |
getindi(indi2, "Ancestor") |
| 51 |
set(connects, 0) |
| 52 |
if(connect(indi1, indi2)) { |
| 53 |
|
| 54 |
forlist(plist, person, pnum) { |
| 55 |
if(ne(pnum, 1)) { |
| 56 |
nl() nl() |
| 57 |
} |
| 58 |
set(x, 0) |
| 59 |
set(skip, left_margin) |
| 60 |
set(x, outfam(person, skip, x)) |
| 61 |
} |
| 62 |
nl() |
| 63 |
" -------------------------------------" |
| 64 |
nl() |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
func connect(person, target) { |
| 69 |
set(connects, 0) |
| 70 |
if(eq(person, target)) { |
| 71 |
set(connects, 1) |
| 72 |
} else { |
| 73 |
if(dad, father(person)) { |
| 74 |
if(connect(dad, target)) { |
| 75 |
set(connects, 1) |
| 76 |
} else { |
| 77 |
if(mom, mother(person)) { |
| 78 |
if(connect(mom, target)) { |
| 79 |
set(connects, 1) |
| 80 |
} |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
if(connects) { |
| 86 |
enqueue(plist, person) |
| 87 |
} |
| 88 |
return(connects) |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
func outfam(indi, skip, x) { |
| 93 |
set(x, outpers(indi, skip, x)) |
| 94 |
if(gt(nfamilies(indi), 0)) { |
| 95 |
set(skip, add(skip, tab_size)) |
| 96 |
families(indi, fam, sp, num) { |
| 97 |
set(x, 0) |
| 98 |
set(x, outline(concat("Family #", d(num)), skip, x)) |
| 99 |
if(date(marriage(fam))) { |
| 100 |
set(x, outline(concat(", ", date(marriage(fam))), skip, x)) |
| 101 |
} |
| 102 |
set(x, 0) |
| 103 |
set(skip, add(skip, tab_size)) |
| 104 |
set(x, outpers(sp, skip, x)) |
| 105 |
if(gt(nchildren(fam), 0)) { |
| 106 |
set(x, outline("Children", skip, x)) |
| 107 |
set(x, 0) |
| 108 |
set(skip, add(skip, tab_size)) |
| 109 |
children(fam, child, no) { |
| 110 |
set(x, outpers(child, skip, x)) |
| 111 |
} |
| 112 |
set(skip, sub(skip, tab_size)) |
| 113 |
} |
| 114 |
set(skip, sub(skip, tab_size)) |
| 115 |
} |
| 116 |
} |
| 117 |
return(x) |
| 118 |
} |
| 119 |
|
| 120 |
func outpers(indi, skip, x) { |
| 121 |
if(indi) { |
| 122 |
print(name(indi), nl()) |
| 123 |
set(x, 0) |
| 124 |
set(x, outline(name(indi), skip, x)) |
| 125 |
set(skip, add(skip, tab_size)) |
| 126 |
set(s, "") |
| 127 |
if(birth(indi)) { |
| 128 |
set(s, concat(", b. ", long(birth(indi)))) |
| 129 |
} |
| 130 |
if(death(indi)) { |
| 131 |
set(s, concat(s, ", d. ", long(death(indi)))) |
| 132 |
} |
| 133 |
if(burial(indi)) { |
| 134 |
set(s, concat(s, ", buried at ", place(burial(indi)))) |
| 135 |
} |
| 136 |
set(s, concat(s, ". ")) |
| 137 |
set(x, outline(s, skip, x)) |
| 138 |
if(note_flag) { |
| 139 |
set(s, "") |
| 140 |
set(note_separator, "") |
| 141 |
fornotes(inode(indi), note) { |
| 142 |
set(s, concat(s, note_separator, note)) |
| 143 |
set(note_separator, " ") |
| 144 |
} |
| 145 |
set(x, outtxt(s, skip, x)) |
| 146 |
set(skip, sub(skip, tab_size)) |
| 147 |
} |
| 148 |
} else { |
| 149 |
print("_____ _____", nl()) |
| 150 |
set(x, 0) |
| 151 |
set(x, outline("_____ _____", skip, x)) |
| 152 |
} |
| 153 |
set(x, 0) |
| 154 |
return(x) |
| 155 |
} |
| 156 |
|
| 157 |
func outtxt(txt, skip, x) { |
| 158 |
set(cr, index(txt, nl(), 1)) |
| 159 |
while(ne(cr, 0)) { |
| 160 |
set(txt, save(txt)) |
| 161 |
set(txt2, concat(substring(txt, 1, sub(cr, 1)), " ")) |
| 162 |
set(x, outline(txt2, skip, x)) |
| 163 |
set(txt, substring(txt, add(cr, 1), strlen(txt))) |
| 164 |
set(cr, index(txt, nl(), 1)) |
| 165 |
} |
| 166 |
if(gt(strlen(txt), 0)) { |
| 167 |
set(x, outline(txt, skip, x)) |
| 168 |
} |
| 169 |
return(x) |
| 170 |
} |
| 171 |
|
| 172 |
func outline(text, skip, x) { |
| 173 |
if(eq(x, 0)) { |
| 174 |
col(add(skip, 1)) |
| 175 |
set(x, skip) |
| 176 |
} |
| 177 |
set(max, sub(page_width, x)) |
| 178 |
if(gt(strlen(text), max)) { |
| 179 |
set(space, breakpoint(text, max)) |
| 180 |
if(eq(space, 0)) { |
| 181 |
if(eq(x, skip)) { |
| 182 |
set(text, strsave(text)) |
| 183 |
substring(text, 1, sub(max, 1)) "-" |
| 184 |
set(x, 0) |
| 185 |
set(text, substring(text, max, strlen(text))) |
| 186 |
set(x, outline(text, skip, x)) |
| 187 |
} else { |
| 188 |
set(x, 0) |
| 189 |
set(x, outline(text, skip, x)) |
| 190 |
} |
| 191 |
} else { /* space gt 0 -- good break point found*/ |
| 192 |
set(text, strsave(text)) |
| 193 |
substring(text, 1, sub(space, 1)) |
| 194 |
set(x, 0) |
| 195 |
set(text, strsave(substring(text, add(space, 1), strlen(text)))) |
| 196 |
while(eqstr(" ", substring(text, 1, 1))) { /* strip leading spaces */ |
| 197 |
set(text, strsave(substring(text, 2, strlen(text)))) |
| 198 |
} |
| 199 |
set(x, outline(text, skip, x)) |
| 200 |
} |
| 201 |
} else { |
| 202 |
text |
| 203 |
set(x, add(x, strlen(text))) |
| 204 |
} |
| 205 |
return(x) |
| 206 |
} |
| 207 |
|
| 208 |
func breakpoint(text, max) { |
| 209 |
set(space, 0) |
| 210 |
set(occ, 1) |
| 211 |
set(next, index(text, " ", occ)) |
| 212 |
incr(occ) |
| 213 |
while ( and(le(next, add(max, 1)), ne (next, 0))) { |
| 214 |
set(space, next) |
| 215 |
set(next, index(text, " ", occ)) |
| 216 |
incr(occ) |
| 217 |
} |
| 218 |
return(space) |
| 219 |
} |