File: ll2visio.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 (319 lines) | stat: -rw-r--r-- 8,597 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
/*
 * @progname       ll2visio.ll
 * @version        1 of 1999-04-02
 * @author         Rafal T. Prinke (rafalp@amu.edu.pl)
 * @category       
 * @output         VISIO 5 diagram
 * @description
 *
 *  This program generates a text file with male line descendants
 *  which can be imported by VISIO 5 and converted to a diagram.
 *
 *  The main procedure is based on Tom Wetmore's _pdesc2_ report.
 *  The procedures "longvitals" and "spousevitals" were originally
 *  based on the same in Tom Wetmore's _register1_ report but
 *  have been changed beyond recognition.
 *
 *  The included procedures "upl2.ll" were written by Paul McBride.
 *
 *  The text file describing a diagram to be constructed in VISIO 5
 *  consists of records (lines) and data fields separated with a comma (.csv)
 *  or a tab (.txt). It can also use an arbitrary delimiter but this report
 *  uses a comma so the output file should be given a .CSV extension.
 *  The CR (hard return) character is not treated as end of record if
 *  enclosed in quotation marks. Comment lines are escaped with a semicolon.
 *  All measurements are in inches.
 *
 *  Here is a quick reference to record types. For one field records
 *  I have added possible values [with explanations in brackets].
 *
 *     <record type,> <field,field,field...>
 *
 *     Master,MasterID,StencilName
 *
 *     PlacementStyle,Style     (0|1|2) [Radial|TopToBottom|LeftToRight]
 *     RoutingStyle,Style       (1|2|3|4|5|) [RightAngle||||Flowchart]
 *
 *     NodeToLineClearance,Horizontal,Vertical
 *     LineToLineClearance,Horizontal,Vertical
 *
 *     Gridding,UseGrid                 (0|1)   [no|yes]
 *     BlockSize,Width,Length
 *     AvenueSize,Width,Height
 *
 *     Template,FileName
 *     Property,Master,RowName,Label,Prompt,Type,Format,Value,Hidden,Ask
 *
 *     Shape,ID,Master,Text,X,Y,Width,Height,Property
 *     Link,ID,Master,Text,From,To
 *
 */

include("upl2.ll")

global(persons)
global(mens)
global(ind1)
global(first)
global(maxgen)
global(upl_tag_list)
global(upl_before_list)
global(upl_after_list)
global(upl_level_list)
global(upl_process_list)
global(upl_out_type)    /* 0 = both, 1 = screen, 2 = file */

proc main () {

        list(persons)
        table(mens)
        call upl_build()
        set(upl_out_type, 2)  /* output to file */

        while(not(indi)) {
             getindi(indi)
        }
        getintmsg(maxgen,"How many generations? ")

        call head(indi)
        call mensae(indi)
        call pout(0, indi)
        set(first,key(indi))

        while(not(empty(persons))) {
             set(p,pop(persons))
             call longvitals(p)
        }
}

/* This procedure produces a list of individuals which is then
 * popped for final output. The reason is that VISIO 5 seems to
 * lay out the shapes from top to bottom and from right to left,
 * so the older children would be on the right and younger on the left,
 * while in traditional genealogical tables the older children are
 * on the left.
 */

proc pout(gen, indi)
{
        push(persons, indi)
        set(next, add(1, gen))
        families(indi,fam,sp,num) {
                if (lt(next,maxgen))  {

/*
    remove the condition below to include all descendants
    (this may not work well yet - father/mother functions need modification)
*/

                        if(eqstr(sex(indi),"M")) {
                                children(fam, child, no) {
                                        call pout(next, child)
                                }
                        }
                }
        }
}

/*
 * The following is the procedure outputting the header of the .csv
 * file for import to VISIO 5. The records field and allowed values
 * can be altered to give intended results.
 */

proc head(u)
{

      "Master,AUTO,Auto-height Box,Basic Flowchart Shapes.VSS\n"
      "Master,CON,Bottom to top variable,Connectors and Callouts.VSS\n"
      "PlacementStyle,1\n"
      "RoutingStyle,1\n"
      ";RoutingStyle,7\n"
      "AvenueSize,0.15,0.15\n"
      "LineToLineClearance,0.1,0.1\n"
      "NodeToLineClearance,0.1,0.1\n"
      "BlockSize,0.2,0.2\n"
      "Gridding,0\n"
      ";Property,AUTO,,,,\n"
      ";Template,\n"
      "\n"
}

/*
 * The remaining procedures define what information goes into
 * one person box. This is rather specific to my files and uses
 * Polish terms so should be adapted to one's needs.
 */


proc longvitals(i)
{
     set(ikey,key(i))
     set(ind1,i)

/*
 * The following line is the beginning of an individual shape (or box)
 * definition, and then the text inside it is constructed.
 * NOTE: if there are quotation marks in the data, there may be problems.
 */

     "Shape," ikey ",AUTO," "\""

/* The following fragment is intended to overcome the "unknown mother"
 * problem when numbering marriages. It is assumed that a dummy FAM record
 * (a) has no WIFE, (b) has the word "ANY" as the wife's name, or (c) has two
 * or more numbers separated with the bar character as her name (e.g. "2|3")
 * when only some wives are possible mothers.
 */


if(nestr(ikey,first)) {
     if (ne(nfamilies(father(i)),1)) {
          if (eqstr(name(mother),"ANY")) {
               "(n) "
          }
          elsif (index(name(mother(i)),"|",1)) {
               "(" name(mother) ") "
          }
          else {
               set(wnm,0)
               families(father(i),a,b,c) {
                       if (wife(parents(i))) {
                            set(wnm,add(wnm,1))
                       }
                       if (eqstr(key(a),key(parents(i)))) {
                            if (wife(parents(i))) {
                                    "(" d(wnm) ") " }
                            else { "(n) " }
                       }
               }
          }
     }
}

/* biographical data report on person is called */

call upl_report(i)

     if (eq(1,nspouses(i))) {
            spouses(i,s,f,n) {
                "; x "
                call spousevitals(s,f)
            }
     } else {
            spouses(i,s,f,n) {
                "; x (" d(n) ") "
                call spousevitals(s,f)
            }
     }

     "\"\n"

/*
 * The following line is the definition of a link between two boxes.
 * The condition excludes up-link from the first person.
 */

if(nestr(ikey,first)) { "Link,,CON,," key(father(i)) "," key(i) "\n" }

}

proc spousevitals (spouse,fam)
{
     set(e,marriage(fam))
     if (and(e,long(e))) { mylong(e) ", " }
     roz(fam)

/* biographical data report on spouse is called */

call upl_report(spouse)

     set(dad,father(spouse))
     set(mom,mother(spouse))
     if (or(dad,mom)) {
            ", "
            if (male(spouse))      { "s. " }
            elsif (female(spouse)) { "dau. " }
            else                   { "ch. " }
     }

     if (dad)          { givens(dad)    /*  "==a"  */
            fornodes(inode(dad), ok) {
                  if (eqstr(tag(ok),"OCCU")) {
                       ", " value(ok)
                  }
            }
     }

/* Other marriages of the spouse. */

     set(srd,0)
     if (gt(nspouses(spouse),1)) { " ["
            spouses(spouse,ind2,fm,nsp) {
                  if (ne(ind2,ind1)) {
                        if (srd) { "; " }
                        " x (" d(nsp) ") "
                        set (es,marriage(fm))
                        if (and(es,long(es))) { mylong(es) " " }
                        roz(fm)
                        name(ind2,0)
                        set(srd,1)
                  }
            }
     "]"
     }
}

func mylong(ev)
{
     list(datum)
     extracttokens(date(ev),datum,n," ")
     forlist(datum,q,n) {
            if (lookup(mens,q)) { lookup(mens,q) }
            else { q }
     }
     if(place(ev)) {
            " (" place(ev) ")"
     }
}


func roz(fx)
{
     fornodes(root(fx), ok) {
            if (eqstr(tag(ok),"DIV")) {
                 ", div."
                 fornodes(ok, dt) {
                       if (eqstr(tag(dt),"DATE")) {
                            " "  mylong(dt)
                       }
                 }
            }
     }
}


/* Table of date tokens follows. */

proc mensae(w)
{
insert(mens,"JAN",".I.")
insert(mens,"FEB",".II.")
insert(mens,"MAR",".III.")
insert(mens,"APR",".IV.")
insert(mens,"MAY",".V.")
insert(mens,"JUN",".VI.")
insert(mens,"JUL",".VII.")
insert(mens,"AUG",".VIII.")
insert(mens,"SEP",".IX.")
insert(mens,"OCT",".X.")
insert(mens,"NOV",".XI.")
insert(mens,"DEC",".XII.")
insert(mens,"BEF","a")
insert(mens,"AFT","p")
insert(mens,"ABT","c")
insert(mens,"CIR","c")
insert(mens,"BET","")
insert(mens,"AND","/")
}