-
Notifications
You must be signed in to change notification settings - Fork 1
/
CATBibcoEval.bas
3033 lines (2921 loc) · 93.3 KB
/
CATBibcoEval.bas
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
'MacroName:BIBCOeval v. 1.0
'MacroDescription: validates displayed record based on BIBCO program requirements
'Macro created by: Tomasz Kalata, BookOps
'Latest update: July 14, 2017
'BibcoEval Macro uses code of the Generate043 macro written by Robert Bremer (bremerr@oclc.org), OCLC WorldCat Quality Division (Revised: Mar. 31, 2013)
Option Explicit
Declare Function RdaBibCoding(t040)
Declare Function Aacr2BibCoding(t040)
Declare Function Normalize(sValue)
Declare Sub DefLangCodes
Declare Sub Add043
Declare Sub UseGenerate043
Dim CS As Object
Dim sLangCode() As String
Dim s043$, sHdg$, sNewGac$
Dim sGac() As String, sGeo() As String
Sub Main
Set CS = GetObject(,"Connex.Client")
If CS.ItemType = 0 or CS.ItemType = 1 or CS.ItemType = 17 Then
'record displayed on the screen
'define variables
Dim sBibType$, sDesc$, sElvl$, sBibcoReqElem$, sLang$, sLitForm, sSrce$, t040$, t041$, t042$
Dim PccAuth, NatLib, ClassPres, NonLatin, nBool, Found, Required 'boolean values
Dim sField$, sValue$, lt$
Dim x as Integer
sBibcoReqElem = "[!BIBCO MANDATORY ELEMENT!]"
'parse commonly accessed fields
'parse record type
CS.GetFixedField "Type", sBibType
'parse Description type
CS.GetFixedField "Desc", sDesc
'parse record level
CS.GetFixedField "ELvl", sElvl
'parse Source from fixed field
CS.GetFixedField "Srce", sSrce
'parse 040
CS.GetField "040", 1, t040
'parse 042 and determine if PCC authenticated bib
If CS.GetField("042", 1, t042) = True Then
If InStr(t042, "pcc") Then
PccAuth = True
Else
PccAuth = False
End If
Else
'not PCC Authenticated bib
PccAuth = False
End If
'determine if national library bib
sValue = Mid(t040, 6, 3)
If InStr("DLC,DNLM,NLM,NLC", sValue) <> 0 Or InStr(t042, "lccopycat") <> 0 Or InStr(t042, "lcode") <> 0 Then
If sSrce = "d" Then
CS.SetFixedField "Srce", "c"
End If
NatLib = True
Else
NatLib = False
End If
'parse literary form if book format
If sBibType = "a" Then
CS.GetFixedField "LitF", sLitForm
Else
sLitForm = "NA"
End If
'validate and populate fixed fields, 040, & 042 fields according to
'BIBCO specifications
' check if new or existing bib
CS.QueryRecordStatus "NUM", sValue
If sValue = "-1" Then
' new bibliographic record
CS.SetFixedField "Srce", "c"
CS.SetFixedField "ELvl", " "
t040 = RdaBibCoding(t040)
CS.SetField 1, t040
Else
'confirm to proceed if ELvl is "i"
If LCase(sElvl) = "i" Then
Begin Dialog Confirm 210, 85, "Confirmation Request"
Text 6, 4, 150, 12, "If ELvl (encoding level) was originally set to 'i'"
Text 6, 12, 200, 12, "it is NOT recommended to upgrade record to BIBCO standard,"
Text 6, 20, 200, 12, "unless your changes are substantional to justify the upgrade."
Text 6, 36, 200, 12, "Upgrade to BIBCO anyway?"
OKButton 35, 55, 60, 20
CancelButton 105, 55, 60, 20
End Dialog
Dim dConfirm As Confirm
If Dialog(dConfirm) <> -1 Then
Goto Terminate
End If
End If
'existing bibliographic record
If NatLib = True Then
If LCase(sElvl) <> " " Then
CS.SetFixedField "ELvl", " "
End If
Else
If LCase(sElvl) <> " " Then
CS.SetFixedField "ELvl", " "
End If
CS.SetFixedField "Srce", "c"
End If
If sDesc = "a" Then
t040 = Aacr2BibCoding(t040)
CS.SetField 1, t040
Else
t040 = RdaBibCoding(t040)
CS.SetField 1, t040
End If
End If
'add PCC authentication code if needed
If PccAuth = False Then
If CS.GetField("042", 1, t042) = False Then
t042 = "042 pcc"
Else:
t042 = RTrim(t042) & " " & Chr(223) & "a pcc"
End If
CS.SetField 1, t042
End If
'add 043 if applicable by running OCLC
If CS.GetField("043", 1, sField) = False Then
UseGenerate043
End If
'determine classification & add missing fields if required
If CS.GetField("050", 1, sField) = True Or CS.GetField("082", 1, sField) = True Then
ClassPres = True
End If
If ClassPres = False Then
If sBibType = "a" Then
CS.GetFixedField "LitF", sLitForm
If InStr("1,f,j", sLitForm) <> 0 Then
CS.AddField 1, "08204[FIC] " & Chr(223) & "2 23"
End If
Else
CS.AddField 1, "082 " & Chr(252) & sBibcoReqElem
End If
End If
'determine if Non-Latin laguages are present and if linked fields in original script are mandatory
CS.GetFixedField "Lang", sLang
If CS.GetField("041", 1, t041) = True Then
sValue = t041
sLang = sLang & "," & Mid(sValue, 6, 3)
Do While InStr(sValue, Chr(223) & "a") <> 0
sValue = LTrim(Mid(sValue, InStr(sValue, Chr(223) & "a") + 2))
sLang = sLang & "," & Mid(sValue, 1, 3)
Loop
End If
DefLangCodes
x = 1
Do
If InStr(sLang, sLangCode(x)) <> 0 Then
NonLatin = True
End If
x = x + 1
Loop Until x >= 21 Or NonLatin = True
If NonLatin = True Then
' verify if at least one of 245s is in Non-Latin script
x = 1
Found = False
Do
nBool = CS.GetField("245", x, sField)
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False Or Found = True
If Found = False Then
CS.AddField x, "245 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
'if 246 present verify if one of them is in Non-Latin script
x = 1
Found = False
Do
nBool = CS.GetField("246", x, sField)
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False
If x > 2 Then
'246 is present
If Found = False Then
CS.AddField x, "246 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
End If
'if 250 present verify if one of them is in Non-Latin script
x = 1
Found = False
Do
nBool = CS.GetField("250", x, sField)
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False
If x > 2 Then
'250 is present
If Found = False Then
CS.AddField x, "250 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
End If
'if 260 present verify if it has linked Non-Latin field
x = 1
Found = False
Required = False
Do
nBool = CS.GetField("260", x, sField)
If nBool = True Then
Required = True
End If
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False
If Found = False And Required = True Then
CS.AddField x, "260 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
'if 264 present verify if one of them is in Non-Latin script
x = 1
Found = False
Required = False
Do
nBool = CS.GetField("264", x, sField)
If nBool = True Then
Required = True
End If
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False
If Found = False And Required = True Then
CS.AddField x, "264 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
'if 490 present verify if one of them is in Non-Latin script
x = 1
Found = False
Do
nBool = CS.GetField("490", x, sField)
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False
If x > 2 Then
'490 is present
If Found = False Then
CS.AddField x, "490 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
End If
'if 740 present verify if one of them is in Non-Latin script
x = 1
Found = False
Do
nBool = CS.GetField("740", x, sField)
If sField = "Data contains non-latin script" Then
Found = True
End If
x = x + 1
Loop Until nBool = False
If x > 2 Then
'740 is present
If Found = False Then
CS.AddField x, "740 " & Chr(252) & sBibcoReqElem & " -- ADD NON-LATIN LINKED FIELD"
End If
End If
End If
'check if 300 present
If CS.GetField("300", 1, sField) = False Then
CS.AddField 1, "300 " & Chr(252) & sBibcoReqElem
End If
'add RDA's 3xx fields if needed
If sBibType = "m" Then
If CS.GetField("347", 1, sField) = False Then
CS.AddField 1, "347 " & Chr(252) & sBibcoReqElem
End If
ElseIf sBibType = "i" Or sBibType = "j" Then
If CS.GetField("344", 1, sField) = False Then
CS.AddField 1, "344 " & Chr(252) & sBibcoReqElem
End If
If CS.GetField("347", 1, sField) = False Then
CS.AddField 1, "347 " & Chr(252) & sBibcoReqElem
End If
ElseIf sBibType = "g" Then
If CS.GetField("344", 1, sField) = False Then
CS.AddField 1, "344 " & Chr(252) & sBibcoReqElem
End If
If CS.GetField("346", 1, sField) = False Then
CS.AddField 1, "346 " & Chr(252) & sBibcoReqElem
End If
If CS.GetField("347", 1, sField) = False Then
CS.AddField 1, "347 " & Chr(252) & sBibcoReqElem
End If
End If
'evaluate if 546 is needed based on content the 041 field
CS.GetFixedField "Lang", sLang
sValue = Mid(t041, 6, 3)
If sValue = sLang Then
sValue = ""
End If
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "a") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "a") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "b") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "b") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "d") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "d") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "e") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "e") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "f") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "f") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "g") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "g") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
lt$ = Mid(t041, 9)
Do While InStr(lt$, Chr(223) & "j") <> 0
lt$ = LTrim(Mid(lt$, InStr(lt$, Chr(223) & "j") + 2))
sValue = sValue & "," & Mid(lt$, 1, 3)
Loop
If Len(sValue) <> 0 Then
If CS.GetField("546", 1, sField) = False Then
CS.AddField 1, "546 " & Chr(252) & sBibcoReqElem
End If
End If
'determine if at least one 6xx is present and add Novels or Short stories genre headings if needed
x = 1
Found = False
Do
nBool = CS.GetField("600", x, sField)
If nBool = True Then
If Mid(sField, 4, 2) = " 0" Then
Found = True
GoTo Done
End If
End If
x = x + 1
Loop Until nBool = False
x = 1
Do
nBool = CS.GetField("610", x, sField)
If nBool = True Then
If Mid(sField, 4, 2) = " 0" Then
Found = True
GoTo Done
End If
End If
x = x + 1
Loop Until nBool = False
x = 1
Do
nBool = CS.GetField("611", x, sField)
If nBool = True Then
If Mid(sField, 4, 2) = " 0" Then
Found = True
GoTo Done
End If
End If
x = x + 1
Loop Until nBool = False
x = 1
Do
nBool = CS.GetField("650", x, sField)
If nBool = True Then
If Mid(sField, 4, 2) = " 0" Then
Found = True
GoTo Done
End If
End If
x = x + 1
Loop Until nBool = False
x = 1
Do
nBool = CS.GetField("651", x, sField)
If nBool = True Then
If Mid(sField, 4, 2) = " 0" Then
Found = True
GoTo Done
End If
End If
x = x + 1
Loop Until nBool = False
x = 1
Do
nBool = CS.GetField("655", x, sField)
If nBool = True Then
If Mid(sField, 4, 2) = " 0" Then
Found = True
GoTo Done
ElseIf Mid(sField, 4, 2) = " 7" Then
If InStr(sField, Chr(223) & "2") <> 0 Then
sValue = Trim(Mid(sField, InStr(sField, Chr(223) & "2")))
If sValue = "lcgft" Or sValue = "gsafd" Then
Found = True
GoTo Done
End If
End If
End If
End If
x = x + 1
Loop Until nBool = False
'add 655 for novels & short stories
If Found = False Then
If sBibType = "a" and InStr("1,f", sLitForm) <> 0 Then
CS.AddField 1, "655 7Novels. " & Chr(223) & "2 lcgft"
ElseIf sBibType = "a" and sLitForm = "j" Then
CS.AddField 1, "655 7Short stories. " & Chr(223) & "2 lcgft"
Else
CS.AddField 1, "650 " & Chr(252) & sBibcoReqElem & " -- ADD AT LEAST ONE SUBJECT (6xx) HEADING"
End If
End If
Done:
'remove 263
x = 1
Do
nBool = CS.GetField("263", x, sField)
If nBool = True Then
MsgBox "trigger"
CS.DeleteField "263", x
End If
x = x + 1
Loop Until nBool = False
'controll all headings
If CS.ControlHeadingsAll() = True Then
MsgBox "All controllable headings were controlled"
Else
MsgBox "Not able to control all headings"
End If
Else
'no record on Connexion screen
MsgBox "A bibliographic record must be displayed in order to user this macro."
End If
Terminate:
End Sub
Function RdaBibCoding(t040)
'ensures correct Desc and the 040 field for RDA record
Dim tNormalized$, lt$, rt$
Dim pos1, pos2
'make sure Desc is coded as "i"
CS.SetFixedField "Desc", "i"
tNormalized = Normalize(t040)
'make sure 040 is properly coded for rda record
If InStr(tNormalized, Chr(223) & "beng" & Chr(223) & "erda") <> 0 Then
GoTo Done
Else
'add or replace subfield $b
pos1 = InStr(t040, Chr(223) & "b")
If pos1 <> 0 Then
'subfield $b present so replace
lt$ = Trim(Left(t040, pos1 - 1))
rt$ = Mid(t040, pos1 + 1)
pos2 = InStr(rt$, Chr(223))
If pos2 = 0 Then
rt$ = ""
Else
rt$ = Trim(Mid(rt$, pos2))
End If
t040 = lt$ & " " & rt$
lt$ = Left(t040, Instr(t040, Chr(223)) - 1)
rt$ = Mid(t040, InStr(t040, Chr(223)))
t040 = RTrim(lt$) & " " & Chr(223) & "b eng " & Trim(rt$)
Else
'no subfield $b so add
pos1 = InStr(t040, Chr(223))
lt$ = Trim(Left(t040, pos1 - 1))
rt$ = Trim(Mid(t040, pos1))
t040 = lt$ & " " & Chr(223) & "b eng " & rt$
End If
'add or replace subfield $e
pos1 = Instr(t040, Chr(223) & "e")
If pos1 <> 0 Then
'remove existing $e coding
lt$ = Trim(Left(t040, pos1 - 1))
rt$ = Trim(Mid(t040, pos1 + 1))
pos2 = InStr(rt$, Chr(223))
If pos2 = 0 Then
rt$ = ""
Else
rt$ = Mid(rt$, pos2)
End If
t040 = lt$ & " " & rt$
'replace $e & instert after $b
pos1 = InStr(t040, Chr(223) & "b")
pos2 = InStr(Mid(t040, pos1 + 1), Chr(223))
lt$ = RTrim(Left(t040, pos1 + pos2 - 1))
rt$ = LTrim(Mid(t040, pos1 + pos2))
t040 = lt$ & " " & Chr(223) & "e rda " & rt$
Else
pos1 = InStr(t040, Chr(223) & "b")
pos2 = InStr(Mid(t040, pos1 + 1), Chr(223))
lt$ = RTrim(Left(t040, pos1 + pos2 - 1))
rt$ = LTrim(Mid(t040, pos1 + pos2))
t040 = lt$ & " " & Chr(223) & "e rda " & rt$
End If
End If
Done:
RdaBibCoding = t040
End Function
Function Aacr2BibCoding(t040)
'ensures correct Desc and the 040 field for AACR2 record
Dim lt$, rt$
Dim pos1%, pos2%
'add or replace $b
pos1 = InStr(t040, Chr(223) & "b")
If pos1 <> 0 Then
'subfield $b present so replace
lt$ = Trim(Left(t040, pos1 - 1))
rt$ = Mid(t040, pos1 + 1)
pos2 = InStr(rt$, Chr(223))
If pos2 = 0 Then
rt$ = ""
Else
rt$ = Trim(Mid(rt$, pos2))
End If
t040 = lt$ & " " & rt$
lt$ = Left(t040, Instr(t040, Chr(223)) - 1)
rt$ = Mid(t040, InStr(t040, Chr(223)))
t040 = RTrim(lt$) & " " & Chr(223) & "b eng " & Trim(rt$)
Else
'no subfield $b so add
pos1 = InStr(t040, Chr(223))
lt$ = Trim(Left(t040, pos1 - 1))
rt$ = Trim(Mid(t040, pos1))
t040 = lt$ & " " & Chr(223) & "b eng " & rt$
End If
Aacr2BibCoding = t040
End Function
Sub DefLangCodes
'defines Non-Latin languge codes
ReDim sLangCode(1 to 20) As String
sLangCode(1) = "ara"
sLangCode(2) = "arm"
sLangCode(3) = "bel"
sLangCode(4) = "ben"
sLangCode(5) = "bul"
sLangCode(6) = "chi"
sLangCode(7) = "eth"
sLangCode(8) = "gre"
sLangCode(9) = "heb"
sLangCode(10) = "jpn"
sLangCode(11) = "kaz"
sLangCode(12) = "kor"
sLangCode(13) = "mac"
sLangCode(14) = "rus"
sLangCode(15) = "scc"
sLangCode(16) = "syr"
sLangCode(17) = "tam"
sLangCode(18) = "tgk"
sLangCode(19) = "tha"
sLangCode(20) = "ukr"
End Sub
Function Normalize(sValue)
Dim x as Integer
Dim CheckChar$, tNormalized$
'normalized passed string
x = 1
While x <= len(sValue):
CheckChar = LCase(Trim(Mid(sValue, x, 1)))
tNormalized = tNormalized & CheckChar
x = x + 1
Wend
Normalize = tNormalized
End Function
' MacroName: Generate043
' MacroDescription: Generates field 043 based on data in 151 & 781 fields in authority records
' or 6xx fields in bibliographic records
' Written by Robert Bremer, OCLC WorldCat Quality Division
' Email: bremerr@oclc.org
' Revised: Mar. 31, 2013
' To generate field 043, retrieve an authority record or workform (containing field 151 and/or
' 781) or a bibliographic record or workform (containing LCSH, LC Children's, MeSH, or Canadian
' subject headings), and run the macro.
' OCLC shall not be liable for any loss or damage, lost profits, loss of business, loss of or
' damage to data, downtime or unavailability, of or in connection with use of materials. OCLC
' shall have no liability for any claims arising from use of the materials, based on
' infringement of copyright, patent, trade secret or other right, libel, slander or invasion of
' privacy or claims based on errors, inaccuracies or omissions in or loss of the data.
' OCLC makes no express warranties or representations and disclaims all implied warranties with
' respect to materials as to their accuracy, merchantability or fitness for a particular purpose.
' Macros are supplied "as is."
Function GetGac(sNrmGeo$) As String
Dim lo%, hi%, x%
lo = 1
hi = 909
x = 1
Do
x = (lo + hi)/2
If sNrmGeo < sGeo(x) Then
hi = x - 1
Else
lo = x + 1
End If
Loop Until lo > hi or sNrmGeo = sGeo(x)
If sNrmGeo = sGeo(x) Then
GetGac = sGac(x)
Else
GetGac = "X"
End If
End Function
Sub DefGac
ReDim sGac(1 to 909) As String
sGac(1) = "u-at-ac"
sGac(2) = "f-cm--- | f-nr---"
sGac(3) = "a-ye---"
sGac(4) = "mr-----"
sGac(5) = "mm-----"
sGac(6) = "e-gr--- | a-tu---"
sGac(7) = "a-af---"
sGac(8) = "f------"
sGac(9) = "fc-----"
sGac(10) = "fe-----"
sGac(11) = "fe-----"
sGac(12) = "f------"
sGac(13) = "fq-----"
sGac(14) = "fw-----"
sGac(15) = "ff-----"
sGac(16) = "fh-----"
sGac(17) = "ff----- | fw-----"
sGac(18) = "fs-----"
sGac(19) = "fb-----"
sGac(20) = "fw-----"
sGac(21) = "n-us-al"
sGac(22) = "n-us-al"
sGac(23) = "n-us-ak"
sGac(24) = "pn-----"
sGac(25) = "e-aa---"
sGac(26) = "n-cn-ab"
sGac(27) = "f-ae---"
sGac(28) = "ea-----"
sGac(29) = "n-cn-ab"
sGac(30) = "sa-----"
sGac(31) = "n------ | s------"
sGac(32) = "poas---"
sGac(33) = "aa-----"
sGac(34) = "i------"
sGac(35) = "sn-----"
sGac(36) = "e-an---"
sGac(37) = "f-ao---"
sGac(38) = "nwxa---"
sGac(39) = "a-cc-an"
sGac(40) = "t------"
sGac(41) = "t------"
sGac(42) = "nwaq---"
sGac(43) = "nwaq---"
sGac(44) = "nw-----"
sGac(45) = "nwla---"
sGac(46) = "n-usa--"
sGac(47) = "n-usa--"
sGac(48) = "mr-----"
sGac(49) = "ma-----"
sGac(50) = "a-mk--- | a-ye---"
sGac(51) = "ar-----"
sGac(52) = "au-----"
sGac(53) = "ps-----"
sGac(54) = "r------"
sGac(55) = "r------"
sGac(56) = "s-ag---"
sGac(57) = "n-us-az"
sGac(58) = "n-us-az"
sGac(59) = "n-us-ar"
sGac(60) = "n-us-ar"
sGac(61) = "a-ai--- | a-ir--- | a-ut---"
sGac(62) = "a-ai---"
sGac(63) = "a-ai---"
sGac(64) = "nwaw---"
sGac(65) = "lsai---"
sGac(66) = "f-gh---"
sGac(67) = "u-ac---"
sGac(68) = "a------"
sGac(69) = "ac-----"
sGac(70) = "l------"
sGac(71) = "n-us---"
sGac(72) = "fa-----"
sGac(73) = "u------"
sGac(74) = "u-at---"
sGac(75) = "u-atn--"
sGac(76) = "u-at-ac"
sGac(77) = "e-au---"
sGac(78) = "e-au--- | e-hu---"
sGac(79) = "a-aj---"
sGac(80) = "a-aj---"
sGac(81) = "lnaz---"
sGac(82) = "a-iq---"
sGac(83) = "nwbf---"
sGac(84) = "a-ba---"
sGac(85) = "ed-----"
sGac(86) = "en-----"
sGac(87) = "ln-----"
sGac(88) = "eb-----"
sGac(89) = "ps-----"
sGac(90) = "a-bg---"
sGac(91) = "nwbb---"
sGac(92) = "nwaq---"
sGac(93) = "r------"
sGac(94) = "f-lo---"
sGac(95) = "e-ne---"
sGac(96) = "n-cn-bc"
sGac(97) = "r------"
sGac(98) = "f-bs---"
sGac(99) = "a-cc-pe"
sGac(100) = "e-bw---"
sGac(101) = "f-cg---"
sGac(102) = "e-be---"
sGac(103) = "ncbh---"
sGac(104) = "el-----"
sGac(105) = "ab-----"
sGac(106) = "f-dm---"
sGac(107) = "s-gy---"
sGac(108) = "pn-----"
sGac(109) = "pn-----"
sGac(110) = "lnbm---"
sGac(111) = "ln-----"
sGac(112) = "a-bt---"
sGac(113) = "f-nr---"
sGac(114) = "mb-----"
sGac(115) = "n-usa--"
sGac(116) = "a-ccp--"
sGac(117) = "s-bo---"
sGac(118) = "nwbn---"
sGac(119) = "a-bn---"
sGac(120) = "e-bn---"
sGac(121) = "ln-----"
sGac(122) = "f-bs---"
sGac(123) = "lsbv---"
sGac(124) = "s-bl---"
sGac(125) = "f-mw---"
sGac(126) = "n-cn-bc"
sGac(127) = "s-gy---"
sGac(128) = "ncbh---"
sGac(129) = "i-bi---"
sGac(130) = "e-uk--- | e-ie---"
sGac(131) = "a-pp---"
sGac(132) = "pobp---"
sGac(133) = "f-so---"
sGac(134) = "nwvb---"
sGac(135) = "a-bx---"
sGac(136) = "e-bu---"
sGac(137) = "f-uv---"
sGac(138) = "a-br---"
sGac(139) = "f-bd---"
sGac(140) = "e-bw---"
sGac(141) = "mm-----"
sGac(142) = "n-us-ca"
sGac(143) = "n-us-ca"
sGac(144) = "a-cb---"
sGac(145) = "f-cm---"
sGac(146) = "f-cm---"
sGac(147) = "n-cn---"
sGac(148) = "n-cn-bc | n-cnp--"
sGac(149) = "nccz---"
sGac(150) = "lnca---"
sGac(151) = "lncv---"
sGac(152) = "cc-----"
sGac(153) = "nwbn--- | nweu--- | nwsd---"
sGac(154) = "cc-----"
sGac(155) = "poci---"
sGac(156) = "ee-----"
sGac(157) = "ak-----"
sGac(158) = "e-urk--"
sGac(159) = "e-urr--"
sGac(160) = "a-ai--- | a-aj--- | a-gs---"
sGac(161) = "nwcj---"
sGac(162) = "a-io--- | a-my--- | a-ph---"
sGac(163) = "f-cx---"
sGac(164) = "f-cx---"
sGac(165) = "nc-----"
sGac(166) = "u-atc--"
sGac(167) = "e-urc--"
sGac(168) = "a-ce---"
sGac(169) = "f-cd---"
sGac(170) = "fq-----"
sGac(171) = "e-uk-ui"
sGac(172) = "n-usl--"
sGac(173) = "n-mx--- | n-ust-- | n-usu--"
sGac(174) = "s-cl---"
sGac(175) = "a-cc---"
sGac(176) = "a-cc-cq"
sGac(177) = "i-xa---"
sGac(178) = "r------"
sGac(179) = "i-xb---"
sGac(180) = "q------"
sGac(181) = "n-us-co"
sGac(182) = "s-ck---"
sGac(183) = "n-us-co"
sGac(184) = "n-usp-- | n-mx---"
sGac(185) = "n-cn-bc | n-us-or | n-us-wa"
sGac(186) = "n-cn-bc | n-usp--"
sGac(187) = "b------"
sGac(188) = "h------"
sGac(189) = "e-ur--- | ee-----"
sGac(190) = "i-cq---"
sGac(191) = "i-cq---"
sGac(192) = "n-usu--"
sGac(193) = "f-cg---"
sGac(194) = "fg-----"
sGac(195) = "fc-----"
sGac(196) = "f-cf---"
sGac(197) = "n-us-ct"
sGac(198) = "n-us-ct"
sGac(199) = "pocw---"
sGac(200) = "u------"
sGac(201) = "u-cs---"
sGac(202) = "nccr---"
sGac(203) = "f-iv---"
sGac(204) = "e-ci---"
sGac(205) = "nwcu---"
sGac(206) = "n-usu--"
sGac(207) = "nwco---"
sGac(208) = "a-cy---"
sGac(209) = "e-xr---"
sGac(210) = "e-cs---"
sGac(211) = "f-dm---"
sGac(212) = "n-us-nd | n-us-sd"
sGac(213) = "eo-----"
sGac(214) = "e------"
sGac(215) = "n-us-dc"
sGac(216) = "zd-----"
sGac(217) = "n-us-de"
sGac(218) = "n-us-de"
sGac(219) = "s-gy---"
sGac(220) = "e-dk---"
sGac(221) = "dd-----"
sGac(222) = "d------"
sGac(223) = "n-us-dc"
sGac(224) = "f-ft---"
sGac(225) = "nwdq---"
sGac(226) = "nwdr---"
sGac(227) = "a-io---"
sGac(228) = "x------"
sGac(229) = "f-ke---"
sGac(230) = "ae-----"
sGac(231) = "an-----"
sGac(232) = "as----- | az-----"
sGac(233) = "e-pl--- | e-ru---"
sGac(234) = "a-em---"
sGac(235) = "poea---"
sGac(236) = "u-ate--"
sGac(237) = "xa-----"
sGac(238) = "n-usr--"
sGac(239) = "s-ec---"
sGac(240) = "f-ua---"
sGac(241) = "nces---"
sGac(242) = "e-uk-en"
sGac(243) = "ln-----"
sGac(244) = "w------"
sGac(245) = "f-eg---"
sGac(246) = "nl----- | n-cn-on | n-us---"
sGac(247) = "f-ea---"
sGac(248) = "s-gy---"
sGac(249) = "e-er---"
sGac(250) = "f-et---"
sGac(251) = "me-----"
sGac(252) = "e------"
sGac(253) = "ec-----"
sGac(254) = "ee-----"
sGac(255) = "en-----"
sGac(256) = "es-----"
sGac(257) = "ew-----"
sGac(258) = "e------"
sGac(259) = "e------"
sGac(260) = "lsfk---"
sGac(261) = "lnfa---"
sGac(262) = "am-----"
sGac(263) = "a-ye---"
sGac(264) = "pofj---"
sGac(265) = "e-fi---"
sGac(266) = "ln-----"
sGac(267) = "n-us-fl"
sGac(268) = "n-us-fl"
sGac(269) = "e-ur---"
sGac(270) = "e-yu---"
sGac(271) = "e-fr---"
sGac(272) = "f-cm---"
sGac(273) = "h------"
sGac(274) = "fq-----"
sGac(275) = "s-fg---"
sGac(276) = "f-gv---"
sGac(277) = "a-ii---"
sGac(278) = "ai-----"
sGac(279) = "pofp---"
sGac(280) = "f-ft---"
sGac(281) = "f-ml---"
sGac(282) = "f-ft---"
sGac(283) = "a-cc-fu"