~ubuntu-branches/ubuntu/trusty/lifelines/trusty

« back to all changes in this revision

Viewing changes to reports/line.ll

  • Committer: Bazaar Package Importer
  • Author(s): Felipe Augusto van de Wiel (faw)
  • Date: 2007-05-23 23:49:53 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20070523234953-ogno9rnbmth61i7p
Tags: 3.0.50-2etch1
* Changing docs/ll-reportmanual.xml and docs/ll-userguide.xml to fix
  documentation build problems (Closes: #418347).

* lifelines-reports
  - Adding a dependency to lifelines >= 3.0.50 to prevent file conflict.
    (Closes: #405500).

* Updating French translation. Thanks to Bernard Adrian. (Closes: #356671).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * @progname       line.ll
 
3
 * @version        1
 
4
 * @author         J.F. Chandler
 
5
 * @category       
 
6
 * @output         Text
 
7
 * @description
 
8
 *
 
9
displays the descendancy line(s) from one person to another.
 
10
This program assumes no individual has more than one set of parents.
 
11
 
 
12
Algorithm partly borrowed from TTW's cousins program.
 
13
 
 
14
Version 1 - 1998 Apr 22 - J.F. Chandler
 
15
 
 
16
  This program requires version 3 of LifeLines.
 
17
*/
 
18
 
 
19
global(link1)   /* table of links back one person */
 
20
global(link2)   /* table of alternate links */
 
21
global(elist)   /* list of chain ends */
 
22
global(dots)    /* person counter */
 
23
 
 
24
proc main () {
 
25
getindimsg(from,"Which ancestor?")
 
26
set(to,0)
 
27
if(from) {
 
28
        getindimsg(to,"Which descendant?")
 
29
}
 
30
if(not(and(from,to))) {
 
31
        print("Not found\n")
 
32
        return()
 
33
}
 
34
set(fkey,save(key(from)))
 
35
set(tkey,save(key(to)))
 
36
"Descendancy line from " name(indi(fkey)) "\nto " name(indi(tkey)) ":\n"
 
37
print("Searching for the line(s) from:\n",name(from)," to ",name(to))
 
38
print(".\n\nThis may take a while -- ")
 
39
print("each dot is 25 persons considered.\n")
 
40
 
 
41
table(link1)
 
42
table(link2)
 
43
list(elist)
 
44
 
 
45
set(dots,0)
 
46
set(found,0)
 
47
set(gen,0)
 
48
set(maxgen,0)
 
49
 
 
50
/* Link the ancestor to self (unique marker), and add as the first
 
51
entry in the list of chain ends.  A "zero" person in the list marks
 
52
the end of a generation. */
 
53
 
 
54
insert(link1,fkey,fkey)
 
55
enqueue(elist,fkey)
 
56
enqueue(elist,0)
 
57
 
 
58
/* Iterate through the list of chain ends, removing them one by one;
 
59
link their children back to them; add the children to the chain end
 
60
list; check each iteration to see if the target person has been found
 
61
through both parents; if so quit the iteration; also quit three
 
62
generations after finding through either parent.  */
 
63
 
 
64
while(gt(length(elist),1)) {
 
65
        set(key,dequeue(elist))
 
66
        if(not(key)) {
 
67
                set(gen,add(1,gen))
 
68
                if(eq(gen,maxgen)) { break() }
 
69
                enqueue(elist,0)
 
70
                continue()
 
71
        }
 
72
        set(indi,indi(key))
 
73
        families(indi,fam,sp,n1) {
 
74
                children(fam,child,n2) {
 
75
                        call include(key,child)
 
76
                }
 
77
        }
 
78
        if(not(found)) {
 
79
                if(lookup(link1,tkey)) {
 
80
                        set(found,1)
 
81
                        set(maxgen,add(3,gen))
 
82
                }
 
83
        } elsif(lookup(link2,tkey)) { break() }
 
84
}
 
85
 
 
86
/* Quit if the "from" is not an ancestor of the "to" person. */
 
87
 
 
88
if(not(found)) {
 
89
        print("\nThere is no such line.")
 
90
        "There is no such line.\n"
 
91
        return()
 
92
}
 
93
 
 
94
set(gen,1)
 
95
"\nWorking back:\n\n1. " call do_person(indi(tkey))
 
96
call printrest(tkey,gen)
 
97
}
 
98
 
 
99
/* Recursively print the rest of the line back to the source.
 
100
If the current person is linked through both parents, also print
 
101
the alternate line starting from here. */
 
102
 
 
103
proc printrest(key,gen) {
 
104
set(gen,add(1,gen))
 
105
set(new,lookup(link1,key))
 
106
if(eq(0,strcmp(key,new))) { return() }
 
107
d(gen) ". " call do_person(father(indi(key)))
 
108
"    & " call do_person(mother(indi(key)))
 
109
if(alt,save(lookup(link2,key))) { "* " }        /* mark a branch point */
 
110
call printrest(new,gen)
 
111
if(alt) {
 
112
        nl()
 
113
        call printrest(alt,gen)
 
114
}}
 
115
 
 
116
/* Link a new child (indi) back to a parent (key).
 
117
If the new child has already been linked once, use alternate table.
 
118
A truly new child is added to the list of chain ends */
 
119
 
 
120
proc include(key,indi) {
 
121
 
 
122
set(dots,add(dots,1))
 
123
if(eq(25,dots)) {
 
124
        set(dots,0)
 
125
        print(".")
 
126
}
 
127
 
 
128
set(new,save(key(indi)))
 
129
if(lookup(link1,key(indi))) {
 
130
        insert(link2,new,key)
 
131
} else {
 
132
        insert(link1,new,key)
 
133
        enqueue(elist,new)
 
134
}}
 
135
 
 
136
/* Print name and dates for a given person */
 
137
 
 
138
proc do_person(p) {
 
139
name(p) " ("
 
140
set(e,birth(p))
 
141
if(not(e)) {set(e,baptism(p))}
 
142
if(e) {date(e)}
 
143
" - "
 
144
set(e,death(p))
 
145
if(not(e)) {set(e,burial(p))}
 
146
if(e) {date(e)}
 
147
")\n"
 
148
}