-
Notifications
You must be signed in to change notification settings - Fork 0
/
GedcomTextFormatter.vb
1532 lines (1520 loc) · 80.7 KB
/
GedcomTextFormatter.vb
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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports System.Collections
Imports System.Collections.Generic
Imports System.Text
Public Class GedcomTextFormatter
Private cSecs As New sections
Private cSrc As New sources
Private cOut As New outSections
Private IncomingText() As String
Private m_strBioText As String = ""
'Private listSourceSections As New List(Of ListsClasses.TI)
Public Function BioText() As String
Return m_strBioText
End Function
Public WriteOnly Property GedcomGeneratedText() As String()
Set(value As String())
IncomingText = value
End Set
End Property
Public WriteOnly Property TargetWTreeRef As String
Set(value As String)
cSecs.MainWikiTreeID = value
End Set
End Property
Public WriteOnly Property TargetName As String
Set(value As String)
cSecs.MainName = value
End Set
End Property
Public WriteOnly Property FatherWTreeRef As String
Set(value As String)
cSecs.FatherWikiTreeID = value
End Set
End Property
Public WriteOnly Property FatherName As String
Set(value As String)
cSecs.FatherName = value
End Set
End Property
Public WriteOnly Property MotherWTreeRef As String
Set(value As String)
cSecs.MotherWikiTreeID = value
End Set
End Property
Public WriteOnly Property MotherName As String
Set(value As String)
cSecs.MotherName = value
End Set
End Property
Public Sub ParseSources()
Dim astr() As String = Nothing
Dim astrSub() As String = Nothing
Dim bBirthSectionPassed As Boolean = False
Dim bBirthDatePassed As Boolean = False
Dim bBirthPlaceWithRefPassed As Boolean = False
Dim bInEventMode As Boolean = False
Dim bInSection As Boolean = False
Dim bNoInfoFound As Boolean = False
Dim bHusbandPassed As Boolean = False
Dim bPassedSource As Boolean = False
Dim bPreBioHeading As Boolean = True
Dim intBiographySectionsCount As Integer = 0
Dim intCounter As Integer = 0
Dim intCounter2 As Integer = 0
Dim intCurrentIndex As Integer = 0
Dim intSourceSectionsCount As Integer = 0
Dim listOutput As New List(Of String)
Dim listRepositories As New List(Of ListsClasses.T2)
Dim listTempLines As New List(Of String)
Dim listYearOrder As New List(Of String)
Dim sbld As StringBuilder = New StringBuilder("")
Dim sbldTemp As StringBuilder = New StringBuilder("")
Dim sectionEnum As IEnumerator = cSecs.GetEnumerator()
Dim sourceEnum As IEnumerator = cSrc.GetEnumerator()
Dim strCurrentEventIndex As String = ""
Dim strCurrentMarriageIndex As String = ""
Dim strCurrentResidenceIndex As String = ""
Dim strLine As String = ""
Dim strMainSection As String = ""
Dim strNewReference As String = ""
Dim strOldReference As String = ""
Dim strTemp As String = ""
Dim thisSection As section
Dim thisSRC As source
For intloop = 0 To IncomingText.Length - 1
If IncomingText(intloop).Trim.StartsWith("== Biography ==") = True Then
intBiographySectionsCount += 1
ElseIf IncomingText(intloop).Trim.StartsWith("== Sources ==") = True Then
intSourceSectionsCount += 1
ElseIf IncomingText(intloop).Contains(" CONT ") = True Then
sbld.Clear()
sbld.Append(IncomingText(intloop))
sbld.Replace(" CONT ", "<br />")
IncomingText(intloop) = sbld.ToString
ElseIf IncomingText(intloop).Contains("''This biography is a rough draft. It was auto-generated") = True Then
'This is a standalone line and can be removed
IncomingText(intloop) = ""
End If
Next
For intloop = IncomingText.Length - 1 To 0 Step -1
If IncomingText(intloop).Trim.StartsWith("* Source: <span id='") = True Then
'* Source: <span id='S13'>S13</span>
sbld.Clear()
sbld.Append(IncomingText(intloop))
sbld.Replace("* Source: <span id='", "")
sbld.Replace("'>", Chr(198))
sbld.Replace("</span>", Chr(198))
astr = sbld.ToString.Split(Chr(198))
'This should now have three parts
'Create the source using part 0
intCounter = cSrc.Add(astr(0))
'Part 1 is identical to part 0 but part 2 holds the text
sbld.Clear()
sbld.Append(astr(2))
sbld.Replace("Type: PHOTO Slideshow: Y", "")
sbld.Replace("Type: PHOTO Slideshow: N", "")
' Primary or Preferred: N
sbld.Replace("Primary or Preferred: N", "")
sbld.Replace("Primary or Preferred: Y", "")
sbld.Replace("Scrapbook: Y", "")
sbld.Replace("Scrapbook: N", "")
sbld.Replace("File: Title: Note:", "")
sbld.Replace("External File: Format: ", "")
sbld.Replace("Publication: Name: Ancestry.com Operations Inc; Location: Provo, UT, USA; ", "")
'What is left should usable text
If sbld.ToString.Contains("Full Text:") = True Then
sbld.Replace("Full Text:", Chr(198))
astr = sbld.ToString.Split(Chr(198))
sbld.Clear()
sbld.Append(astr(0))
End If
cSrc(intCounter).SourceText = sbld.ToString.Trim
cSrc(intCounter).SourceInLineCode = "<ref name=" & Chr(34) & cSrc(intCounter).ID & Chr(34) & " />"
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Trim.StartsWith("* Repository: <span id='") = True Then
'* Repository: <span id='REPO6'>REPO6</span> Name: Ancestry.com
sbld.Clear()
sbld.Append(IncomingText(intloop))
sbld.Replace("* Repository: <span id='", "")
sbld.Replace("</span>", "")
sbld.Replace("Name:", Chr(198))
sbld.Replace("'", "")
astr = sbld.ToString.Split(Chr(198))
astrSub = astr(0).Split(">")
listRepositories.Add(New ListsClasses.T2(astrSub(0), astr(1).Trim))
IncomingText(intloop) = ""
ElseIf IncomingText(intloop) = "== Sources ==" Then
If intSourceSectionsCount > 1 AndAlso bPassedSource = False Then
bPassedSource = True
ElseIf intSourceSectionsCount > 1 AndAlso bPassedSource = True Then
bPassedSource = False
Exit For
Else
Exit For
End If
End If
Next
'Now parse all the sources and replace the repository with the details
'[[#REPO6]]
For Each element In listRepositories
sourceEnum.Reset()
While sourceEnum.MoveNext()
thisSRC = sourceEnum.Current()
If thisSRC.SourceText.Trim.Contains(element.FirstValue.Trim) = True Then
sbld.Clear()
sbld.Append(thisSRC.SourceText)
strTemp = "[[#" & element.FirstValue & "]]"
sbld.Replace(strTemp, element.SecondValue.Trim)
thisSRC.SourceText = sbld.ToString
End If
End While
thisSRC = Nothing
Next
For intloop = 0 To IncomingText.Length - 1
If IncomingText(intloop).Contains("auto-generated by a GEDCOM") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains("... He passed away") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains("''Can you add any information") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains("''No sources. The events of") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains("<!-- Please edit, add, or delete anything in this text") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains("''No more info is currently available. Can you add") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains(":: User ID:") = True Then
IncomingText(intloop) = ""
ElseIf IncomingText(intloop).Contains(":: Record ID Number:") = True Then
IncomingText(intloop) = ""
End If
Next
'Now the text is split into sections
'A prebio section is created just in case
intCurrentIndex = cSecs.Add("PreBiography")
For intloop = 0 To IncomingText.Length - 1
If IncomingText(intloop).StartsWith("== ") = True Then
'This is a major level 1 section like Biography or Sources
sbld.Clear()
sbld.Append(IncomingText(intloop))
sbld.Replace("=", "")
intCurrentIndex = cSecs.Add(sbld.ToString.Trim)
If sbld.ToString.Trim.StartsWith("Bio") = True Then
bPreBioHeading = False
End If
cSecs(intCurrentIndex).SectionLevel = 1
strMainSection = cSecs(intCurrentIndex).ID
bInSection = True
ElseIf IncomingText(intloop).StartsWith("=== ") = True Then
If IncomingText(intloop).Contains("Data Changed") = True OrElse IncomingText(intloop).Contains("External File") = True OrElse IncomingText(intloop).Contains("Reference") = True OrElse IncomingText(intloop).Contains("User ID") = True Then
'We skip this one
bInSection = False
Else
'This is a level 2 section
strTemp = cSecs(intCurrentIndex).ID
sbld.Clear()
sbld.Append(IncomingText(intloop))
sbld.Replace("=", "")
If sbld.ToString = "Census" Then
intCurrentIndex = cSecs.Add("Residence")
Else
intCurrentIndex = cSecs.Add(sbld.ToString.Trim)
End If
cSecs(intCurrentIndex).SectionLevel = 2
cSecs(intCurrentIndex).ParentSection = strMainSection
bInSection = True
End If
Else
If bInSection = True Then
If IncomingText(intloop).Trim > "" Then
cSecs(intCurrentIndex).Lines.Add(IncomingText(intloop))
End If
Else
If bPreBioHeading = True Then
cSecs(intCurrentIndex).Lines.Add(IncomingText(intloop))
End If
End If
End If
Next
'Now we can write these back oot again in the right order
'Sections can be
'Biography. Don't ignore this it may have data
' Birth
' Death
' Occupation
' Residence = may have many subsections
sectionEnum.Reset()
While sectionEnum.MoveNext
thisSection = sectionEnum.Current
Select Case thisSection.ID.ToLower
Case "acknowledgements"
For Each strLine In thisSection.Lines
cOut.Acknowledgements.OtherLines.Add(RemoveLeadColons(strLine))
Next
Case "baptism", "christening"
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
cOut.BaptismData.SectionDate = CDate(strTemp)
cOut.BaptismData.DateStatus = DATE_CERT
Else
cOut.BaptismData.DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.BaptismData.SectionDateString = strTemp
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.BaptismData.SectionPlace = sbld.ToString.Trim
Else
cOut.BaptismData.OtherLines.Add(RemoveLeadColons(strLine))
End If
Next
Case "biography"
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
cOut.BiographyLines.OtherLines.Add(RemoveLeadColons(strLine))
Next
Case "birth"
listTempLines.Clear()
For Each strLine In thisSection.Lines
listTempLines.Add(strLine)
Next
For Each strLine In thisSection.Lines
If strLine.Trim.StartsWith(": Birth:") = False Then
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
If bBirthDatePassed = False Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
cOut.BirthData.SectionDate = CDate(strTemp)
cOut.BirthData.DateStatus = DATE_CERT
Else
cOut.BirthData.DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.BirthData.SectionDateString = strTemp
End If
bBirthDatePassed = True
ElseIf bBirthPlaceWithRefPassed = True Then
'Mm, we have a date and place with a reference so this is possibly spurious
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
If cOut.BirthData.SectionDate <> CDate(strTemp) Then
cOut.BirthData.OtherLines.Add("Additional birth date recorded: " & strTemp)
End If
End If
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
If bBirthPlaceWithRefPassed = False Then
cOut.BirthData.SectionPlace = sbld.ToString.Trim
If sbld.ToString.Contains("<ref>Source: [[#") Then
bBirthPlaceWithRefPassed = True
End If
Else
If cOut.BirthData.SectionPlace.StartsWith(sbld.ToString) = False Then
cOut.BirthData.OtherLines.Add("Additional birth place recorded: " & sbld.ToString)
End If
End If
Else
cOut.BirthData.OtherLines.Add(RemoveLeadColons(strLine))
End If
End If
Next
Case "burial"
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
cOut.BurialData.SectionDate = CDate(strTemp)
cOut.BurialData.DateStatus = DATE_CERT
Else
cOut.BurialData.DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.BurialData.SectionDateString = strTemp
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.BurialData.SectionPlace = sbld.ToString.Trim
Else
cOut.BurialData.OtherLines.Add(RemoveLeadColons(strLine))
End If
Next
Case "census", "residence"
': Residence: Marital Status: Married; Relation to Head of House: Head
':: Date: 1881
':: Place: 19 Gt Francis St, Aston, Birmingham, Warwickshire<ref>Source: [[#S33]] </ref><ref>Source: [[#S13]] Page: Class: RG11; Piece: 3032;
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine.Trim)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
strCurrentResidenceIndex = Year(strTemp).ToString
cOut.ResidenceData.Add(strCurrentResidenceIndex)
cOut.ResidenceData(strCurrentResidenceIndex).SectionDate = CDate(strTemp)
cOut.ResidenceData(strCurrentResidenceIndex).DateStatus = DATE_CERT
Else
strCurrentResidenceIndex = strTemp.Trim
cOut.ResidenceData.Add(strCurrentResidenceIndex)
cOut.ResidenceData(strCurrentResidenceIndex).DateStatus = DATE_CERT
End If
If sbldTemp.Length > 0 Then
cOut.ResidenceData(strCurrentResidenceIndex).OtherLines.Add(sbldTemp.ToString)
End If
sbldTemp.Clear()
If listTempLines.Count > 0 Then
For Each strTemp In listTempLines
cOut.ResidenceData(strCurrentResidenceIndex).OtherLines.Add(strTemp)
Next
listTempLines.Clear()
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.ResidenceData(strCurrentResidenceIndex).SectionPlace = sbld.ToString.Trim
ElseIf strLine.Trim.StartsWith(": Residence:") Then
'This may be just 'residence' or may have other data
'If only residence ignore it otherwies hive off the data to the first line
'eith way this is a new residence once the year is known
strCurrentResidenceIndex = ""
sbldTemp.Clear()
If strLine.Trim.Length > 13 Then
sbldTemp.Append(strLine.Substring(13))
End If
Else
If strCurrentResidenceIndex.Trim > "" Then
cOut.ResidenceData(strCurrentResidenceIndex).OtherLines.Add(RemoveLeadColons(strLine))
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
End If
Next
Case "children"
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
ElseIf strLine.Trim.StartsWith(":: Place:") Then
End If
Next
Case "death"
For Each strLine In thisSection.Lines
If strLine.Trim.StartsWith(": Death:") = False Then
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
cOut.DeathData.SectionDate = CDate(strTemp)
cOut.DeathData.DateStatus = DATE_CERT
Else
cOut.DeathData.DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.DeathData.SectionDateString = strTemp
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.DeathData.SectionPlace = sbld.ToString.Trim
Else
cOut.DeathData.OtherLines.Add(RemoveLeadColons(strLine))
End If
End If
Next
Case "divorce"
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
cOut.DivorceData.SectionDate = CDate(strTemp)
cOut.DivorceData.DateStatus = DATE_CERT
Else
cOut.DivorceData.DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.DivorceData.SectionDateString = strTemp
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.DivorceData.SectionPlace = sbld.ToString.Trim
Else
cOut.DivorceData.OtherLines.Add(RemoveLeadColons(strLine))
End If
Next
Case "event"
'This is only for events with the level 3 heading === Event ====
listTempLines.Clear()
For Each strLine In thisSection.Lines
If strLine.Trim.StartsWith(": Event:") = False Then
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
strCurrentEventIndex = cOut.EventsData.Add(Year(strTemp).ToString)
cOut.EventsData(strCurrentEventIndex).EventDate = CDate(strTemp)
cOut.EventsData(strCurrentEventIndex).DateStatus = DATE_CERT
Else
strCurrentEventIndex = cOut.EventsData.Add(strTemp)
cOut.EventsData(strCurrentEventIndex).DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.EventsData(strCurrentEventIndex).EventDateString = strTemp
End If
If listTempLines.Count > 0 Then
For Each strTemp In listTempLines
If strTemp.Contains("Type") = True Then
sbld.Clear()
sbld.Append(strTemp)
sbld.Replace("Type:", "")
cOut.EventsData(strCurrentEventIndex).EventType = strTemp.Trim
ElseIf strTemp.Contains("Place") = True Then
sbld.Clear()
sbld.Append(strTemp)
sbld.Replace("Place:", "")
cOut.EventsData(strCurrentEventIndex).EventPlace = strTemp.Trim
Else
cOut.EventsData(strCurrentEventIndex).OtherLines.Add(strTemp)
End If
Next
listTempLines.Clear()
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
If strCurrentEventIndex > "" Then
sbld.Replace(":: Place:", "")
cOut.EventsData(strCurrentEventIndex).EventPlace = sbld.ToString.Trim
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
ElseIf strLine.Trim.StartsWith(":: Type:") Then
If strCurrentEventIndex > "" Then
sbld.Replace(":: Type:", "")
cOut.EventsData(strCurrentEventIndex).EventType = sbld.ToString
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
Else
If strCurrentEventIndex.Trim > "" Then
cOut.EventsData(strCurrentEventIndex).OtherLines.Add(RemoveLeadColons(strLine))
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
End If
Else
strCurrentEventIndex = ""
If listTempLines.Count > 0 Then
'An undated event, or one with an unrecognided date is left in the buffer
strCurrentEventIndex = cOut.EventsData.Add(Year(Today).ToString)
For Each strTemp In listTempLines
If strTemp.Contains("Type") = True Then
sbld.Clear()
sbld.Append(strTemp)
sbld.Replace("Type:", "")
cOut.EventsData(strCurrentEventIndex).EventType = sbld.ToString.Trim
ElseIf strTemp.Contains("Place") = True Then
sbld.Clear()
sbld.Append(strTemp)
sbld.Replace("Place:", "")
cOut.EventsData(strCurrentEventIndex).EventPlace = sbld.ToString.Trim
Else
cOut.EventsData(strCurrentEventIndex).OtherLines.Add(strTemp)
End If
Next
listTempLines.Clear()
strCurrentEventIndex = ""
End If
End If
Next
Case "general"
'This gets added to notes and placed at the end
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
cOut.NotesData.OtherLines.Add(RemoveLeadColons(strLine))
Next
Case "marriage"
For Each strLine In thisSection.Lines
'The User ID line turns off the in event mode
If strLine.Trim.StartsWith(": User ID:") = False Then
'check for person
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
'check for father
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
'check for mother
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
'We don't need the marriage line it just acts as a switch
If strLine.StartsWith(": Marriage:") = True Then
bInEventMode = False
strCurrentMarriageIndex = ""
ElseIf strCurrentMarriageIndex > "" AndAlso strLine.Contains("Husband") = True Then
'This is the start of a new marriage
strCurrentMarriageIndex = ""
listTempLines.Add(RemoveLeadColons(strLine))
Else
'Get ready
sbld.Clear()
sbld.Append(strLine)
If strLine.StartsWith(": Event:") Then
bInEventMode = True
If strCurrentMarriageIndex.Trim > "" Then
cOut.MarriageData(strCurrentMarriageIndex).OtherLines.Add(RemoveLeadColons(strLine))
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
Else
If bInEventMode = True Then
If strCurrentMarriageIndex.Trim > "" Then
cOut.MarriageData(strCurrentMarriageIndex).OtherLines.Add(RemoveLeadColons(strLine))
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
Else
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
strCurrentMarriageIndex = Year(strTemp).ToString
cOut.MarriageData.Add(strCurrentMarriageIndex)
cOut.MarriageData(strCurrentMarriageIndex).SectionDate = CDate(strTemp)
cOut.MarriageData(strCurrentMarriageIndex).DateStatus = DATE_CERT
Else
strCurrentMarriageIndex = strTemp.Trim
cOut.MarriageData.Add(strCurrentMarriageIndex)
cOut.MarriageData(strCurrentMarriageIndex).DateStatus = ParsePartialDate(strTemp)
End If
If sbldTemp.Length > 0 Then
cOut.MarriageData(strCurrentMarriageIndex).OtherLines.Add(sbldTemp.ToString)
End If
If listTempLines.Count > 0 Then
For Each strTemp In listTempLines
If strTemp.Contains("Husband:") = True Then
cOut.MarriageData(strCurrentMarriageIndex).Husband = strTemp.Substring(10).Trim
bHusbandPassed = True
ElseIf strTemp.Contains("Wife:") = True Then
cOut.MarriageData(strCurrentMarriageIndex).Wife = strTemp.Substring(7).Trim
ElseIf strTemp.Contains("Child:") = True Then
cOut.MarriageData(strCurrentMarriageIndex).Children.Add(strTemp.Substring(8).Trim)
Else
cOut.MarriageData(strCurrentMarriageIndex).OtherLines.Add(strTemp)
End If
Next
listTempLines.Clear()
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.MarriageData(strCurrentMarriageIndex).SectionPlace = sbld.ToString.Trim
Else
If strCurrentMarriageIndex.Trim > "" Then
cOut.MarriageData(strCurrentMarriageIndex).OtherLines.Add(RemoveLeadColons(strLine))
Else
listTempLines.Add(RemoveLeadColons(strLine))
End If
End If
End If
End If
End If
Else
bInEventMode = False
strCurrentMarriageIndex = ""
End If
Next
Case "note", "notes", "research note", "research notes"
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
cOut.NotesData.OtherLines.Add(RemoveLeadColons(strLine))
Next
Case "occupation"
'Puts this into bio
For Each strLine In thisSection.Lines
If CheckForMainID(strLine, strTemp) = True Then
cSecs.MainName = strTemp
End If
If CheckForFatherID(strLine, strTemp) = True Then
cSecs.FatherName = strTemp
End If
If CheckForMotherID(strLine, strTemp) = True Then
cSecs.MotherName = strTemp
End If
sbld.Clear()
sbld.Append(strLine)
If strLine.Trim.StartsWith(":: Date:") Then
sbld.Replace(":: Date:", "")
strTemp = sbld.ToString.Trim
If IsDate(strTemp) = True Then
'This is a valid date
'Setting this automatically sets the year of the section
cOut.BiographyLines.SectionDate = CDate(strTemp)
cOut.BiographyLines.DateStatus = DATE_CERT
Else
cOut.BiographyLines.DateStatus = ParsePartialDate(strTemp)
'strTemp has been 'Fixed'
cOut.BiographyLines.SectionDateString = strTemp
End If
ElseIf strLine.Trim.StartsWith(":: Place:") Then
sbld.Replace(":: Place:", "")
cOut.BiographyLines.SectionPlace = sbld.ToString.Trim
Else
cOut.BiographyLines.OtherLines.Add(RemoveLeadColons(strLine))
End If
Next
Case "prebiography"
'This really only covers any stray line at the start that have probably been added later
For Each strLine In thisSection.Lines
cOut.PreBio.OtherLines.Add(RemoveLeadColons(strLine))
Next
Case "sources"
'This really only covers any stray sources that have probably been added later
For Each strLine In thisSection.Lines
If strLine.Contains("created through the import of ") = True Then
'This is a gedcom import line that has got stuffed into the sources
sbld.Clear()
sbld.Append(strLine)
sbld.Replace("* ", "")
cOut.Acknowledgements.OtherLines.Add(sbld.ToString)
Else
cOut.SourcesData.OtherLines.Add(RemoveLeadColons(strLine))
End If
Next
End Select
End While
'Collate the lines
If cOut.PreBio.OtherLines.Count > 0 Then
For Each strline In cOut.PreBio.OtherLines
listOutput.Add(strline)
Next
End If
If cSrc.Count = 0 Then
listOutput.Add("{{unsourced}}")
End If
listOutput.Add("==Biography==")
If cOut.BiographyLines.OtherLines.Count > 0 Then
For Each strline In cOut.BiographyLines.OtherLines
listOutput.Add(":" & strLine)
If strLine.Contains("No more info is currently available") = True Then
bNoInfoFound = True
End If
Next
End If
'Before writing the timeline we need tp determine the correct order.
'This can be done from the section years
If cOut.BaptismData.SectionYear > 0 Then
listYearOrder.Add(cOut.BaptismData.SectionYear.ToString & "|" & "baptism")
End If
If cOut.BirthData.SectionYear > 0 Then
listYearOrder.Add(cOut.BirthData.SectionYear.ToString & "|" & "birth")
End If
If cOut.BurialData.SectionYear > 0 Then
listYearOrder.Add(cOut.BurialData.SectionYear.ToString & "|" & "burial")
End If
If cOut.DeathData.SectionYear > 0 Then
listYearOrder.Add(cOut.DeathData.SectionYear.ToString & "|" & "death")
End If
If cOut.DivorceData.SectionYear > 0 Then
listYearOrder.Add(cOut.DivorceData.SectionYear.ToString & "|" & "divorce")
End If
If cOut.EventsData.Count > 0 Then
For intloop = 1 To cOut.EventsData.Count
If cOut.EventsData(intloop).EventYear > 0 Then
listYearOrder.Add(cOut.EventsData(intloop).EventYear.ToString & "|event")
End If
Next
End If
If cOut.MarriageData.Count > 0 Then
For intloop = 1 To cOut.MarriageData.Count
If cOut.MarriageData(intloop).SectionYear > 0 Then
listYearOrder.Add(cOut.MarriageData(intloop).SectionYear.ToString & "|marriage")
End If
Next
End If
'Notes data is alsways used
If cOut.ResidenceData.Count > 0 Then
For intloop = 1 To cOut.ResidenceData.Count
If cOut.ResidenceData(intloop).SectionYear > 0 Then
listYearOrder.Add(cOut.ResidenceData(intloop).SectionYear.ToString & "|residence")
End If
Next
End If
If listYearOrder.Count > 0 Then
listYearOrder.Sort()
End If
listOutput.Add("==Timeline==")
For Each strYearIndex In listYearOrder
astr = strYearIndex.Split("|")
Select Case astr(1)
Case "baptism"
If cOut.BaptismData.HasData = True Then
If cOut.BaptismData.SectionYear > 0 Then
listOutput.Add("===" & cOut.BaptismData.SectionYear.ToString & " Baptism===")
Else
listOutput.Add("===Baptism===")
End If
sbld.Clear()
sbld.Append(":")
If cSecs.MainName.Trim > "" Then
sbld.Append(cSecs.MainName)
If cSecs.FatherName.Trim > "" Then
sbld.Append(", child of ")
sbld.Append(cSecs.FatherName)
End If
If cSecs.MotherName.Trim > "" Then
If cSecs.FatherName.Trim > "" Then
sbld.Append(" and ")
Else
sbld.Append(", child of ")
End If
sbld.Append(cSecs.MotherName)
End If
Else
sbld.Append("''[enter name here]''")
End If
sbld.Append(" was baptised")
Select Case cOut.BaptismData.DateStatus
Case DATE_ABT
sbld.Append(" about ")
sbld.Append(cOut.BaptismData.SectionDateString)
Case DATE_AFT
sbld.Append(" after ")
sbld.Append(cOut.BaptismData.SectionDateString)
Case DATE_BFR
sbld.Append(" before ")
sbld.Append(cOut.BaptismData.SectionDateString)
Case DATE_CERT
sbld.Append(" on ")
sbld.Append(cOut.BaptismData.SectionDate.ToString("dd MMM yyyy"))
Case DATE_UNK
If cOut.BaptismData.SectionYear > 0 Then
sbld.Append(" in ")
sbld.Append(CStr(cOut.BaptismData.SectionYear))
sbld.Append(" on an unknown day or month ")
Else
sbld.Append(" on an unknown date ")
End If
End Select
If cOut.BaptismData.SectionPlace.Trim > "" Then
sbld.Append(" at ")
sbld.Append(cOut.BaptismData.SectionPlace)
End If
listOutput.Add(sbld.ToString)
If cOut.BaptismData.OtherLines.Count > 0 Then
listOutput.Add("")
For Each strLine In cOut.BaptismData.OtherLines
listOutput.Add(":" & strLine)
Next
End If
End If
Case "birth"
If cOut.BirthData.HasData = True Then
If cOut.BirthData.SectionYear > 0 Then
listOutput.Add("===" & cOut.BirthData.SectionYear.ToString & " Birth===")
Else
listOutput.Add("===Birth===")
End If
sbld.Clear()
sbld.Append(":")
If cSecs.MainName.Trim > "" Then
sbld.Append(cSecs.MainName)
If cSecs.FatherName.Trim > "" Then
sbld.Append(", child of ")
sbld.Append(cSecs.FatherName)
End If
If cSecs.MotherName.Trim > "" Then
If cSecs.FatherName.Trim > "" Then
sbld.Append(" and ")
Else
sbld.Append(", child of ")
End If
sbld.Append(cSecs.MotherName)
End If
Else
sbld.Append("''[enter name here]''")
End If
sbld.Append(" was born")
Select Case cOut.BirthData.DateStatus
Case DATE_ABT
sbld.Append(" about ")
sbld.Append(cOut.BirthData.SectionDateString)
Case DATE_AFT
sbld.Append(" after ")
sbld.Append(cOut.BirthData.SectionDateString)
Case DATE_BFR
sbld.Append(" before ")
sbld.Append(cOut.BirthData.SectionDateString)
Case DATE_CERT
sbld.Append(" on ")
sbld.Append(cOut.BirthData.SectionDate.ToString("dd MMM yyyy"))
Case DATE_UNK
If cOut.BirthData.SectionYear > 0 Then
sbld.Append(" in ")
sbld.Append(CStr(cOut.BirthData.SectionYear))
sbld.Append(" on an unknown day or month ")
Else
sbld.Append(" on an unknown date ")
End If
End Select
If cOut.BirthData.SectionPlace.Trim > "" Then
sbld.Append(" at ")
sbld.Append(cOut.BirthData.SectionPlace)
End If
listOutput.Add(sbld.ToString)
If cOut.BirthData.OtherLines.Count > 0 Then
listOutput.Add("")
For Each strLine In cOut.BirthData.OtherLines
listOutput.Add(":" & strLine)
Next
End If
bBirthSectionPassed = True
End If
Case "burial"
If cOut.BurialData.HasData = True Then