123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423 |
- Attribute VB_Name = "ReRomanize"
- Option Explicit
- #Const EvaluateFirstCharacterDebug = 0 ' -1 ' 0 ' -1 ' 0 ' -1
- #Const FindFieldCurrentlyPointedToDebug = 0 ' -1
- #Const ReRomanizeAdjustNFIDebug = 0 ' -1
- #Const ReRomanizeTextDebug = 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1
- #Const ReRomanizeTextDetailsDebug = 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1
- #Const ReRomanizeTextDetailsBasicsDebug = 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1
- #Const RomanizationAssistanceDebug = 0 ' -1 ' 0 ' -1 ' 0 ' -1 ' 0 ' -1
- #Const RomanizeHighlightedTextDebug = 0 ' -1
- #Const RomanizeWholeRecordDebug = 0 ' -1 ' 0 '-1
- Private Const ArialUnicodeMS$ = "Arial Unicode MS"
- Private Const LucidaSansUnicode$ = "Lucida Sans Unicode"
- Private Const NotoSans$ = "Noto Sans"
- Private Const NotoSerif$ = "Noto Serif"
- Private Const TextFormattedDefaultFont$ = ArialUnicodeMS$
- Private Const sAuthorityNonfilingString$ = "130:2 430:2 530:2"
- Private Const sBibliographicNonfilingString$ = "130:1 240:2 242:2 243:2 245:2 440:2 630:1 730:1 740:1 830:2"
- Private Const sCommunityInfoNonfilingString$ = "245:2 440:2 630:1 730:1 740:1"
- Private prvsRightToLeftMarker$, prvsLeftToRightMarker$
- Private Const CHARACTERSET_CODES_FOR_880_BasicAsG0$ = "(B"
- Private Const CHARACTERSET_CODES_FOR_880_HebrewAsG0$ = "(2"
- Private Const CHARACTERSET_CODES_FOR_880_BasicCyrillicAsG0$ = "(N"
- Private Const CHARACTERSET_CODES_FOR_880_BasicArabicAsG0$ = "(3"
- Private Const CHARACTERSET_CODES_FOR_880_GreekAsG0$ = "(S"
- Private Const CHARACTERSET_CODES_FOR_880_CJKAsG0$ = "$1"
- Private Const CHARACTERSET_CODES_FOR_880_ExtendedCyrillicAsG1$ = ")Q"
- Private Const CHARACTERSET_CODES_FOR_880_ExtendedArabicAsG1$ = ")4"
- Private Const CHARACTERSET_CODES_FOR_880_ExtendedLatinAsG1$ = ")!E"
- Private Const CharSetU2MTranslation$ = "*****-1s s -2g*g *-3b b -4p p -5? (2 -6? (N -7? (3 -8g*(S*-9? $1 -:? (Q -;? (4 "
- Global Const ROMANIZATIONACTION_DisplayMarcRecord% = 1
- Global Const ROMANIZATIONACTION_RomanizeHighlightedText% = 2
- Global Const ROMANIZATIONACTION_RomanizeWholeRecord% = 3
- Global Const ROMANIZATIONACTION_UCaseWord% = 4
- Global Const ROMANIZATIONACTION_LCaseWord% = 5
- Global Const ROMANIZATIONACTION_ReplaceText% = 6
- Global Const ROMANIZATIONACTION_UCaseEach% = 7
- Global Const ROMANIZATIONACTION_Define% = 8
- Enum RomanizationAction
- DefineSubstitution = ROMANIZATIONACTION_Define%
- DisplayMarcRecord = ROMANIZATIONACTION_DisplayMarcRecord%
- LowercaseWord = ROMANIZATIONACTION_LCaseWord%
- ReplaceText = ROMANIZATIONACTION_ReplaceText%
- RomanizeHighlightedText = ROMANIZATIONACTION_RomanizeHighlightedText%
- RomanizeWholeRecord = ROMANIZATIONACTION_RomanizeWholeRecord%
- UppercaseWord = ROMANIZATIONACTION_UCaseWord%
- UppercaseEachWord = ROMANIZATIONACTION_UCaseEach%
- End Enum
- Global Const ROMANIZATIONRESULT_Success% = 0
- Global Const ROMANIZATIONRESULT_TextNotHighlighted% = 1
- Global Const ROMANIZATIONRESULT_HighlightedTextBecomesNothing% = 2
- Global Const ROMANIZATIONRESULT_TextNotFindable% = 3
- Global Const ROMANIZATIONRESULT_ActionUnclear% = 4
- Global Const ROMANIZATIONRESULT_FieldNotFound% = 5
- Global Const ROMANIZATIONRESULT_880WithNoSubfield6% = 6
- Global Const ROMANIZATIONRESULT_880NotAllowed% = 7
- Global Const ROMANIZATIONRESULT_880AlreadyPresent% = 8
- Global Const ROMANIZATIONRESULT_NoCharacterToDefine% = 9
- Global Const ROMANIZATIONRESULT_FileOpen% = 10
- Global Const ROMANIZATIONDIRECTION_Unknown% = 0
- Global Const ROMANIZATIONDIRECTION_Roman2Vernacular% = 1
- Global Const ROMANIZATIONDIRECTION_Vernacular2Roman% = 2
- Type ROMANIZATIONDETAILTYPE
- FullString As String
- Equivalent As String
- EquivalentUpperCase As String
- FullStringLengthInCharacters As Integer
- FullStringLengthInBytes As Integer
- EquivalentUpperCasePresent As Boolean
- InitialOnly As Boolean
- TerminalOnly As Boolean
- MedialOnly As Boolean
- End Type
- Type ROMANIZATIONDETAILARRAY
- Detail() As ROMANIZATIONDETAILTYPE
- DetailLast As Long
- DetailMax As Long
- End Type
- Type ROMANIZATIONTABLETYPE
- Vernacular2Roman As Object
- Roman2Vernacular As Object
- Name As String
- FullFileName As String
- Vernacular() As ROMANIZATIONDETAILARRAY
- Roman() As ROMANIZATIONDETAILARRAY
- VernacularLast As Long
- VernacularMax As Long
- RomanLast As Long
- RomanMax As Long
- AllowCaseVariation As Boolean
- AllowDefineButton As Boolean
- ApostropheCharacters As String
- ApostropheCharactersPresent As Boolean
- BySyllables As Boolean
- DoNotUse880Field As Boolean
- FontName As String
- NoRomanization As Boolean
-
- R2VCreateEmpty880s As Boolean
- R2VFieldsIncluded As String
- R2VIncludeFormattingCharactersLcPattern As Boolean
- R2VOtherSubfieldsExcludedByTag As String
- R2VSubfieldsAlwaysExcluded As String
- R2VSubfield6Code As String
- R2VVowelMarker As String
-
- V2RCreateEmptyFields As Boolean
- V2RFieldsIncluded As String
- V2ROtherSubfieldsExcludedByTag As String
- V2RSubfieldsAlwaysExcluded As String
- V2RUppercaseFirstCharacterInSubfield As String
- V2RPersonalNameUppercase As Boolean
- End Type
- Type RESEQUENCETABLETYPE
- Tag As String * 3
- LinkTag As String * 3
- Field As String
- Field880 As String
- Sequence As Integer
- Sequence880 As Integer
- End Type
- Public Type ROMANIZATIONSCRIPTTYPE
- Name As String
- LoadScript As Boolean
- FileSize As Long
- End Type
- Global gblaReSequenceTable() As RESEQUENCETABLETYPE
- Global gblaRomanizationScript() As ROMANIZATIONSCRIPTTYPE
- Global gblaRomanizationTable() As ROMANIZATIONTABLETYPE
- Global gbliReSequenceTableLast%
- Global gbliRomanizationScriptLast%
- Global gbliRomanizationTableLast%, gbliRomanizationTableMax%
- Global gbliRomanizationTablesBytes#
- Public Function ReRomanizeText(ByVal sRecordType$, ByVal sTag$, ByVal sText$, ByVal iRomanizationTable%, ByRef LocalMarcRecordObject As Utf8MarcRecordClass, ByRef LocalMarcCharacter As Utf8CharClass, Optional ByRef iRomanizationDirection% = -1, Optional ByVal sSubfieldCode$ = "") As String
- Dim sOut$, sLeft$, sRight$, sWord$
- Dim iLength%
-
- Dim lPtr As Long, lLength As Long
-
- Dim bFound As Boolean
-
-
- On Error GoTo 0
-
- If iRomanizationTable% < 1 Or iRomanizationTable% > gbliRomanizationTableLast% Then
- sOut$ = sText$
- Else
- If iRomanizationDirection% = -1 Then
- iRomanizationDirection% = EvaluateFirstCharacter(sText$, iRomanizationTable%, LocalMarcCharacter)
- End If
- Select Case iRomanizationDirection%
- Case ROMANIZATIONDIRECTION_Unknown%
- sOut$ = sText$
- Case ROMANIZATIONDIRECTION_Roman2Vernacular%
- sOut$ = ReRomanizeTextDetails(sText$, gblaRomanizationTable(iRomanizationTable%).Roman2Vernacular, gblaRomanizationTable(iRomanizationTable%).Roman(), LocalMarcRecordObject, LocalMarcCharacter, True, iRomanizationTable%)
- Case ROMANIZATIONDIRECTION_Vernacular2Roman%
- sOut$ = ReRomanizeTextDetails(sText$, gblaRomanizationTable(iRomanizationTable%).Vernacular2Roman, gblaRomanizationTable(iRomanizationTable%).Vernacular(), LocalMarcRecordObject, LocalMarcCharacter, False, iRomanizationTable%)
- If gblaRomanizationTable(iRomanizationTable%).V2RPersonalNameUppercase Then
-
-
-
- Select Case sRecordType$
- Case "A"
- If InStr("100 400 500", sTag$) > 0 Then
- ReRomanizeTextPersonalNameHandling:
- lPtr = InStr(sOut$, LocalMarcRecordObject.MarcDelimiter + "a")
- If lPtr > 0 Then
- sLeft$ = Mid(sOut$, 1, lPtr + 1)
- sOut$ = Mid(sOut$, lPtr + 2)
- ElseIf Mid(sOut$, 1, 1) = LocalMarcRecordObject.MarcDelimiter Then
- GoTo ReRomanizeTextNoPNH
- Else
- sLeft$ = ""
- End If
- lPtr = InStr(sOut$, LocalMarcRecordObject.MarcDelimiter)
- If lPtr > 0 Then
- sRight$ = Mid(sOut$, lPtr)
- sOut$ = Mid(sOut$, 1, lPtr - 1)
- Else
- sRight$ = ""
- End If
- sOut$ = Trim(sOut$)
-
- lPtr = InStr(sOut$, " ")
- If lPtr > 0 Then
- sLeft$ = sLeft$ + LocalMarcRecordObject.UCaseFirstWord(Mid(sOut$, 1, lPtr - 1) + ",")
- sOut$ = Trim(Mid(sOut$, lPtr + 1))
- Do While Len(sOut$) > 0
- GetNextPiece sOut$, sWord$, " "
- sLeft$ = sLeft$ + " " + LocalMarcRecordObject.UCaseFirstWord(sWord$)
- Loop
- End If
- sOut$ = sLeft$ + sOut$ + sRight$
- End If
- ReRomanizeTextNoPNH:
- Case "B"
- If InStr("100 400 600 700 800", sTag$) > 0 Then
- GoTo ReRomanizeTextPersonalNameHandling
- End If
- End Select
- End If
- If Len(gblaRomanizationTable(iRomanizationTable%).V2RUppercaseFirstCharacterInSubfield) > 0 Then
- If InStr(gblaRomanizationTable(iRomanizationTable%).V2RUppercaseFirstCharacterInSubfield, sTag$) > 0 Then
- If InStr(sOut$, LocalMarcRecordObject.MarcDelimiter) > 0 Then
-
- For lPtr = Len(sOut$) - 2 To 1 Step -1
- If Mid(sOut$, lPtr, 1) = LocalMarcRecordObject.MarcDelimiter Then
- If InStr(gblaRomanizationTable(iRomanizationTable%).V2RUppercaseFirstCharacterInSubfield, sTag$ + "/" + Mid(sOut$, lPtr + 1, 1)) > 0 Then
- sOut$ = Mid(sOut$, 1, lPtr + 1) + LocalMarcRecordObject.UCaseFirstWord(Mid(sOut$, lPtr + 2))
- End If
- End If
- Next
- ElseIf Len(sSubfieldCode$) > 0 Then
- If InStr(gblaRomanizationTable(iRomanizationTable%).V2RUppercaseFirstCharacterInSubfield, sTag$ + "/" + sSubfieldCode$) > 0 Then
- sOut$ = LocalMarcRecordObject.UCaseFirstWord(sOut$)
- End If
- End If
- End If
- End If
- End Select
- End If
-
- ReRomanizeText = LocalMarcRecordObject.RemoveRepeatedCharacters(sOut$, " ")
-
-
-
- End Function
- Public Sub LoadOneRomanizationTable(ByVal sFileNameIncludingPath$, ByRef LocalMarcRecordObject As Utf8MarcRecordClass, ByRef LocalCharacterObject As Utf8CharClass, ByRef sDefaultFieldsIncluded$, Optional ByRef ProgressBarCtrl As Control = Nothing)
-
-
-
-
- Dim iIn%, iMode%, iElement%, iRc%, iRc2%, iRc3%
-
- Dim sRight$, sLeft$, sUpperCase$, sTruncation$, sOriginal$
-
- Dim bLeft As Boolean, bRight As Boolean
-
- sTruncation$ = "%"
-
- iIn% = FreeFile
- On Error GoTo LRFT_FileOpenError
- Open sFileNameIncludingPath$ For Input As #iIn%
- On Error GoTo 0
-
-
- gbliRomanizationTableLast% = gbliRomanizationTableLast% + 1
- If gbliRomanizationTableLast% > gbliRomanizationTableMax% Then
- gbliRomanizationTableMax% = gbliRomanizationTableMax% + 5
- ReDim Preserve gblaRomanizationTable(0 To gbliRomanizationTableMax%)
- End If
-
- With gblaRomanizationTable(gbliRomanizationTableLast%)
-
-
- .FullFileName = sFileNameIncludingPath$
-
-
- .R2VFieldsIncluded = sDefaultFieldsIncluded$
- .V2RFieldsIncluded = sDefaultFieldsIncluded$
-
- .R2VSubfieldsAlwaysExcluded = "uvxy0123456789"
- .V2RSubfieldsAlwaysExcluded = "uvxy0123456789"
-
- .R2VOtherSubfieldsExcludedByTag = ""
- .V2ROtherSubfieldsExcludedByTag = ""
-
- .R2VIncludeFormattingCharactersLcPattern = False
-
- .R2VSubfield6Code = ""
-
-
- .R2VVowelMarker = ""
-
- Set .Roman2Vernacular = CreateObject("Scripting.Dictionary")
- Set .Vernacular2Roman = CreateObject("Scripting.Dictionary")
-
- .AllowDefineButton = False
- .FontName = ""
-
- Do While Not EOF(iIn%)
- Line Input #iIn%, sRight$
-
-
- If Not ProgressBarCtrl Is Nothing Then
- DoEvents
-
- LoadRomanizationTablesProgress Len(sRight$) + 2, ProgressBarCtrl
- End If
-
- If Len(sRight$) > 0 Then
- If Mid(sRight$, 1, 1) <> "#" Then
- If Mid(sRight$, 1, 1) = "[" Then
- Select Case Trim(UCase(sRight$))
- Case "[GENERAL]"
- iMode% = 1
- Case "[ROMANTOSCRIPT]"
- iMode% = 2
- Case "[SCRIPTTOROMAN]"
- iMode% = 3
- Case Else
- If .NoRomanization Then
- Exit Do
- End If
- iMode% = 4
- End Select
-
- Else
-
- Select Case iMode%
-
- Case 1
- GetNextPiece sRight$, sLeft$, "="
- Select Case sLeft$
- Case "Name"
- .Name = sRight$
- Case "FontName"
-
-
- .FontName = sRight$
- Case "NoRomanization"
-
- .NoRomanization = LocalMarcRecordObject.IsTrue(sRight$)
- Case "DoNotUse880Field"
- .DoNotUse880Field = LocalMarcRecordObject.IsTrue(sRight$)
- Case "AllowCaseVariation"
- .AllowCaseVariation = LocalMarcRecordObject.IsTrue(sRight$)
- Case "ApostropheCharacters"
-
- .ApostropheCharacters = RomanizeConvertText(sRight$, LocalMarcRecordObject, LocalCharacterObject)
- If Len(.ApostropheCharacters) > 0 Then
- .ApostropheCharactersPresent = True
- End If
- Case "AllowDefineButton"
- .AllowDefineButton = LocalMarcRecordObject.IsTrue(sRight$)
- Case "BySyllables"
- .BySyllables = LocalMarcRecordObject.IsTrue(sRight$)
- Case "Truncation"
- sTruncation$ = sRight$
- End Select
-
- Case 2
-
- If InStr(sRight$, "=") > 0 Then
- GetNextPiece sRight$, sLeft$, "="
- Select Case sLeft$
- Case "FieldsIncluded"
- .R2VFieldsIncluded = sRight$
- GoTo LORT_NextLine
- Case "IncludeFormattingCharactersLcPattern"
-
- .R2VIncludeFormattingCharactersLcPattern = True
- GoTo LORT_NextLine
- Case "CreateEmpty880s"
- .R2VCreateEmpty880s = True
- GoTo LORT_NextLine
- Case "Subfield6Code"
- .R2VSubfield6Code = sRight$
- GoTo LORT_NextLine
- Case "SubfieldsAlwaysExcluded"
- .R2VSubfieldsAlwaysExcluded = sRight$
- GoTo LORT_NextLine
- Case "OtherSubfieldsExcludedByTag"
- .R2VOtherSubfieldsExcludedByTag = sRight$
- GoTo LORT_NextLine
- Case "VowelMarker"
-
- .R2VVowelMarker = sRight$
- GoTo LORT_NextLine
- End Select
- LORT_RTV_ContinueWithDividedLine:
- bLeft = False
- bRight = False
- If Mid(sLeft$, 1, 1) = sTruncation$ Then
- bLeft = True
- sLeft$ = Mid(sLeft$, 2)
- End If
- If Right(sLeft$, 1) = sTruncation$ Then
- bRight = True
- sLeft$ = Mid(sLeft$, 1, Len(sLeft$) - 1)
- End If
-
- sRight$ = RomanizeConvertText(sRight$, LocalMarcRecordObject, LocalCharacterObject)
- sLeft$ = RomanizeConvertText(sLeft$, LocalMarcRecordObject, LocalCharacterObject)
-
-
- sUpperCase$ = Mid(sRight$, 1, iRc% - 1)
- sRight$ = Mid(sRight$, iRc% + 1)
- Else
- sUpperCase$ = ""
- End If
- LocalCharacterObject.Utf8Char = sLeft$
- If .Roman2Vernacular.Exists(LocalCharacterObject.Utf8Char) Then
- iElement% = .Roman2Vernacular.item(LocalCharacterObject.Utf8Char)
- Else
- .RomanLast = .RomanLast + 1
- If .RomanLast > .RomanMax Then
- .RomanMax = .RomanMax + 10
- ReDim Preserve .Roman(0 To .RomanMax)
- End If
- iElement% = .RomanLast
- .Roman2Vernacular.Add LocalCharacterObject.Utf8Char, iElement%
- End If
- .Roman(iElement%).DetailLast = .Roman(iElement%).DetailLast + 1
- If .Roman(iElement%).DetailLast > .Roman(iElement%).DetailMax Then
- .Roman(iElement%).DetailMax = .Roman(iElement%).DetailMax + 5
- ReDim Preserve .Roman(iElement%).Detail(0 To .Roman(iElement%).DetailMax)
- End If
- If .AllowCaseVariation Then
- .Roman(iElement%).Detail(.Roman(iElement%).DetailLast).FullString = LocalMarcRecordObject.SafeLCase(sLeft$)
-
- .Roman(iElement%).Detail(.Roman(iElement%).DetailLast).EquivalentUpperCase = sUpperCase$
- .Roman(iElement%).Detail(.Roman(iElement%).DetailLast).EquivalentUpperCasePresent = True
- End If
- If bLeft Then
- If bRight Then
- .Roman(iElement%).Detail(.Roman(iElement%).DetailLast).MedialOnly = True
- Else
- .Roman(iElement%).Detail(.Roman(iElement%).DetailLast).TerminalOnly = True
- End If
- ElseIf bRight Then
- .Roman(iElement%).Detail(.Roman(iElement%).DetailLast).InitialOnly = True
- End If
-
- ElseIf InStr(sRight$, vbTab) > 0 Then
-
- GetNextPiece sRight$, sLeft$, vbTab
- GoTo LORT_RTV_ContinueWithDividedLine
-
- End If
-
- Case 3
-
- If InStr(sRight$, "=") > 0 Then
-
- GetNextPiece sRight$, sLeft$, "="
- Select Case sLeft$
- Case "CreateEmptyFields"
- .V2RCreateEmptyFields = True
- GoTo LORT_NextLine
- Case "FieldsIncluded"
- .V2RFieldsIncluded = sRight$
- GoTo LORT_NextLine
- Case "SubfieldsAlwaysExcluded"
- .V2RSubfieldsAlwaysExcluded = sRight$
- GoTo LORT_NextLine
- Case "OtherSubfieldsExcludedByTag"
- .V2ROtherSubfieldsExcludedByTag = sRight$
- GoTo LORT_NextLine
- Case "UppercaseFirstCharacterInSubfield"
- .V2RUppercaseFirstCharacterInSubfield = sRight$
- GoTo LORT_NextLine
- Case "PersonalNameHandling"
- .V2RPersonalNameUppercase = LocalMarcRecordObject.IsTrue(sRight$)
- GoTo LORT_NextLine
- End Select
- LORT_VTR_ContinueWithDividedLine:
- bLeft = False
- bRight = False
- If Mid(sLeft$, 1, 1) = sTruncation$ Then
- bLeft = True
- sLeft$ = Mid(sLeft$, 2)
- End If
- If Right(sLeft$, 1) = sTruncation$ Then
- bRight = True
- sLeft$ = Mid(sLeft$, 1, Len(sLeft$) - 1)
- End If
-
- sRight$ = RomanizeConvertText(sRight$, LocalMarcRecordObject, LocalCharacterObject)
- sLeft$ = RomanizeConvertText(sLeft$, LocalMarcRecordObject, LocalCharacterObject)
- iRc% = InStr(sRight$, "/")
- If iRc% > 0 Then
- sUpperCase$ = Mid(sRight$, 1, iRc% - 1)
- sRight$ = Mid(sRight$, iRc% + 1)
- Else
- sUpperCase$ = ""
- End If
- LocalCharacterObject.Utf8Char = sLeft$
-
- If .Vernacular2Roman.Exists(LocalCharacterObject.Utf8Char) Then
- iElement% = .Vernacular2Roman.item(LocalCharacterObject.Utf8Char)
- Else
- .VernacularLast = .VernacularLast + 1
- If .VernacularLast > .VernacularMax Then
- .VernacularMax = .VernacularMax + 10
- ReDim Preserve .Vernacular(0 To .VernacularMax)
- End If
- iElement% = .VernacularLast
- .Vernacular2Roman.Add LocalCharacterObject.Utf8Char, iElement%
- End If
- .Vernacular(iElement%).DetailLast = .Vernacular(iElement%).DetailLast + 1
- If .Vernacular(iElement%).DetailLast > .Vernacular(iElement%).DetailMax Then
- .Vernacular(iElement%).DetailMax = .Vernacular(iElement%).DetailMax + 5
- ReDim Preserve .Vernacular(iElement%).Detail(0 To .Vernacular(iElement%).DetailMax)
- End If
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).FullString = sLeft$
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).FullStringLengthInCharacters = LocalMarcRecordObject.SafeLen(sLeft$)
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).FullStringLengthInBytes = Len(sLeft$)
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).Equivalent = sRight$
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).EquivalentUpperCasePresent = False
- If bLeft Then
- If bRight Then
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).MedialOnly = True
- Else
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).TerminalOnly = True
- End If
- ElseIf bRight Then
- .Vernacular(iElement%).Detail(.Vernacular(iElement%).DetailLast).InitialOnly = True
- End If
-
-
- ElseIf InStr(sRight$, vbTab) > 0 Then
- GetNextPiece sRight$, sLeft$, vbTab
- GoTo LORT_VTR_ContinueWithDividedLine
- End If
-
- End Select
- End If
- End If
- End If
- LORT_NextLine:
- Loop
- If Len(.Name) = 0 Then
- .Name = "Unknown script #" + Trim(str(gbliRomanizationTableLast%))
- End If
-
- End With
-
- Close #iIn%
-
- LRFT_FileOpenErrorresume:
- Exit Sub
-
- LRFT_FileOpenError:
- Resume LRFT_FileOpenErrorresume
-
- End Sub
- Public Function RomanizeConvertText(ByVal sIn$, ByRef LocalMarcRecordObject As Utf8MarcRecordClass, ByRef LocalCharacterObject As Utf8CharClass) As String
-
- Dim lPtr As Long
-
- Dim sLeader$, sOriginal$
-
- Dim bShow As Boolean
-
-
- sIn$ = LocalMarcRecordObject.ReplaceCharacters(sIn$, "_", " ")
-
- sLeader$ = "&H"
-
- Do
- lPtr = InStr(sIn$, sLeader$)
- Do While lPtr > 0
- LocalCharacterObject.UcsHex = Mid(sIn$, lPtr + 2, 4)
- sIn$ = LocalMarcRecordObject.SafeStuff(sIn$, lPtr, 6, LocalCharacterObject.Utf8Char)
- lPtr = InStr(sIn$, sLeader$)
- Loop
- Select Case sLeader$
- Case "&H"
- sLeader$ = "U+"
- Case "U+"
- sLeader$ = "&x"
- Case "&x"
- sLeader$ = "&X"
- Case "&X"
- sLeader$ = "&h"
- Case "&h"
- Exit Do
- End Select
- Loop
-
- LoadOneRomanizationTable sConfigurationFilePath$ + sFile$, LocalMarcRecordObject, LocalCharacterObject, sDefaultFieldsIncluded$, ProgressBarCtrl
- If bDebug Then
- MsgBox "For " + Trim(str(iCtr%)) + " read: >" + sConfigurationFilePath$ + sFile$ + "< vernacular entries " + str(gblaRomanizationTable(gbliRomanizationTableLast%).VernacularLast) + " roman entries " + str(gblaRomanizationTable(gbliRomanizationTableLast%).RomanLast)
- End If
- End If
- Else
- If LenB(Dir$(sFile$)) > 0 And gblaRomanizationScript(iCtr%).LoadScript Then
- LoadOneRomanizationTable sFile$, LocalMarcRecordObject, LocalCharacterObject, sDefaultFieldsIncluded$, ProgressBarCtrl
- If bDebug Then
- MsgBox "For " + Trim(str(iCtr%)) + " read: >" + sFile$ + "< vernacular entries " + str(gblaRomanizationTable(gbliRomanizationTableLast%).VernacularLast) + " roman entries " + str(gblaRomanizationTable(gbliRomanizationTableLast%).RomanLast)
- End If
- End If
- End If
- iCtr% = iCtr% + 1
- Loop
-
-
- End Sub
- Public Sub DumpRomanizationTables()
- Dim iCtr%, iCtr2%, iCtr3%
-
- For iCtr% = 1 To gbliRomanizationTableLast%
- With gblaRomanizationTable(iCtr%)
- Debug.Print "Name: " + .Name
- Debug.Print "Roman to vernacular"
- For iCtr2% = 1 To .RomanLast
- With .Roman(iCtr2%)
- For iCtr3% = 1 To .DetailLast
- Debug.Print vbTab + .Detail(iCtr3%).FullString + vbTab + .Detail(iCtr3%).Equivalent
- Next
- End With
- Next
- Debug.Print "Vernacular to roman"
- For iCtr2% = 1 To .VernacularLast
- With .Vernacular(iCtr2%)
- For iCtr3% = 1 To .DetailLast
- Debug.Print vbTab + .Detail(iCtr3%).FullString + vbTab + .Detail(iCtr3%).Equivalent
- Next
- End With
- Next
- End With
- Next
-
- End Sub
- Public Sub LoadListOfScriptsIntoControl(ByRef c As Control)
- Dim iCtr%
- With c
- If c.style = vbListBoxCheckbox Then
- c.Clear
- For iCtr% = 1 To gbliRomanizationScriptLast%
- .AddItem gblaRomanizationScript(iCtr%).Name
- .Selected(iCtr% - 1) = gblaRomanizationScript(iCtr%).LoadScript
- Next
- Else
- If .ListCount = 0 Then
- For iCtr% = 1 To gbliRomanizationTableLast%
- .AddItem gblaRomanizationTable(iCtr%).Name
- Next
- If .ListCount > 0 Then
- .ListIndex = 0
- End If
- End If
- End If
- End With
- End Sub
- Private Function ReRomanizeTextDetails(ByVal sText$, ByRef oRomanizationTable As Object, ByRef RomanizationTable() As ROMANIZATIONDETAILARRAY, ByRef LocalMarcRecordObject As Utf8MarcRecordClass, ByRef LocalMarcCharacter As Utf8CharClass, ByVal bRoman2Vernacular As Boolean, ByVal iRomanizationTable%)
- Dim iLen%, iLengthBeforeApostropheSubstitution%
-
- Dim lPtr As Long, lPtr2 As Long, lMember As Long, lCtr As Long, lEnd As Long
-
- Dim sOut$, sPreviousCharacter$, sSyllable$, sChar1$, sChar2$, sOriginalSyllable$
-
- Dim bFound As Boolean, bFirstCharacter As Boolean, bFirstCharacterIsUppercase As Boolean
- Dim bApostrophes As Boolean, bWholeThingIsUppercase As Boolean, bChanged As Boolean
- Dim bAllowCaseVariation
-
-
-
- lPtr = 1
- lEnd = Len(sText$)
-
- bApostrophes = gblaRomanizationTable(iRomanizationTable%).ApostropheCharactersPresent
-
-
- If gblaRomanizationTable(iRomanizationTable%).AllowCaseVariation Then
- bAllowCaseVariation = True
- End If
-
- If Not gblaRomanizationTable(iRomanizationTable%).BySyllables Then
-
-
- bFirstCharacter = True
- Do While lPtr <= lEnd
- bFound = False
- If lPtr > 1 Then
- sPreviousCharacter$ = LocalMarcCharacter.Utf8Char
- If sPreviousCharacter$ = " " Then
- bFirstCharacterIsUppercase = False
- End If
- End If
- LocalMarcCharacter.Utf8Char = Mid(sText$, lPtr)
-
-
- If bAllowCaseVariation Then
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- LocalMarcCharacter.Utf8Char = LocalMarcRecordObject.SafeLCase(LocalMarcCharacter.Utf8Char)
- If bFirstCharacter Or sPreviousCharacter$ = " " Then
- bFirstCharacterIsUppercase = True
- End If
- End If
- End If
- If InStr("Lu Ll Lo", LocalMarcCharacter.Utf8CharCategory) > 0 Then
- bFirstCharacter = False
- End If
- If LocalMarcCharacter.Utf8Char = LocalMarcCharacter.MarcDelimiter Then
- sOut$ = sOut$ + Mid(sText$, lPtr, 2)
- lPtr = lPtr + 1
- iLen% = 1
- Else
- iLen% = LocalMarcCharacter.Utf8CharOctets
- If oRomanizationTable.Exists(LocalMarcCharacter.Utf8Char) Then
- lMember = oRomanizationTable.item(LocalMarcCharacter.Utf8Char)
- With RomanizationTable(lMember)
- For lCtr = 1 To .DetailLast
- If .Detail(lCtr).InitialOnly Then
-
-
-
- If lPtr + .Detail(lCtr).FullStringLengthInBytes >= lEnd Then
-
- GoTo RRTD_NextDetail
- ElseIf InStr(" -.?,;:!""])" + LocalMarcRecordObject.MarcDelimiter, Mid(sText$, lPtr + .Detail(lCtr).FullStringLengthInBytes, 1)) > 0 Then
-
- GoTo RRTD_NextDetail
- ElseIf lPtr = 1 Then
-
-
-
- ElseIf InStr(" -""[(", Mid(sText$, lPtr - 1, 1)) > 0 Then
-
-
-
- ElseIf lPtr > 2 Then
- If Mid(sText$, lPtr - 2, 1) = LocalMarcRecordObject.MarcDelimiter Then
-
- Else
- GoTo RRTD_NextDetail
- End If
- Else
-
- GoTo RRTD_NextDetail
- End If
- ElseIf .Detail(lCtr).TerminalOnly Then
-
-
-
-
-
-
- If lPtr + .Detail(lCtr).FullStringLengthInBytes > lEnd Then
-
- ElseIf InStr(" -.?,;:!""])" + LocalMarcRecordObject.MarcDelimiter, Mid(sText$, lPtr + .Detail(lCtr).FullStringLengthInBytes, 1)) > 0 Then
-
-
- Else
-
- GoTo RRTD_NextDetail
- End If
-
-
- ElseIf .Detail(lCtr).MedialOnly Then
-
-
-
-
- If lPtr = 1 Then
-
- GoTo RRTD_NextDetail
- ElseIf InStr(" -""[(", Mid(sText$, lPtr - 1, 1)) > 0 Then
-
-
- GoTo RRTD_NextDetail
- ElseIf lPtr > 2 Then
- If Mid(sText$, lPtr - 2, 1) = LocalMarcRecordObject.MarcDelimiter Then
-
- GoTo RRTD_NextDetail
- End If
-
-
- ElseIf lPtr + .Detail(lCtr).FullStringLengthInBytes >= lEnd Then
-
- GoTo RRTD_NextDetail
- ElseIf InStr(" -.?,;:!""])" + LocalMarcRecordObject.MarcDelimiter, Mid(sText$, lPtr + .Detail(lCtr).FullStringLengthInBytes, 1)) > 0 Then
-
- GoTo RRTD_NextDetail
- End If
-
-
- End If
-
-
-
- If bRoman2Vernacular Then
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- If Not bApostrophes Then
- If Mid(sText, lPtr, .Detail(lCtr).FullStringLengthInBytes) = .Detail(lCtr).FullString Then
- bFound = True
- If .Detail(lCtr).EquivalentUpperCasePresent Then
- If Len(sPreviousCharacter$) = 0 Then
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- Else
- LocalMarcCharacter.Utf8Char = sPreviousCharacter$
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- sOut$ = sOut$ + .Detail(lCtr).EquivalentUpperCase
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- End If
- bChanged = True
- iLen% = .Detail(lCtr).FullStringLengthInBytes
- Else
- If bFirstCharacterIsUppercase Then
- sOut$ = sOut$ + LocalMarcRecordObject.UCaseFirstWord(.Detail(lCtr).Equivalent)
- bFirstCharacterIsUppercase = False
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- bChanged = True
- iLen% = .Detail(lCtr).FullStringLengthInBytes
- End If
- Exit For
- End If
- Else
- If ReRomanizeTextDetailsReplaceApostrophes(LocalMarcRecordObject.SafeUCase(LocalMarcRecordObject.SafeMid(sText, lPtr, .Detail(lCtr).FullStringLengthInCharacters)), iRomanizationTable%, LocalMarcCharacter, iLengthBeforeApostropheSubstitution%) = .Detail(lCtr).FullString Then
- bFound = True
- If .Detail(lCtr).EquivalentUpperCasePresent Then
- If Len(sPreviousCharacter$) = 0 Then
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- Else
- LocalMarcCharacter.Utf8Char = sPreviousCharacter$
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- sOut$ = sOut$ + .Detail(lCtr).EquivalentUpperCase
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- End If
- bChanged = True
- iLen% = iLengthBeforeApostropheSubstitution%
- Else
- If bFirstCharacterIsUppercase Then
- sOut$ = sOut$ + LocalMarcRecordObject.UCaseFirstWord(.Detail(lCtr).Equivalent)
- bFirstCharacterIsUppercase = False
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- bChanged = True
- iLen% = iLengthBeforeApostropheSubstitution%
- End If
- Exit For
- End If
- End If
- Else
- If Not bApostrophes Then
- If Mid(sText, lPtr, .Detail(lCtr).FullStringLengthInBytes) = .Detail(lCtr).FullString Or (bAllowCaseVariation And LCase(Mid(sText, lPtr, .Detail(lCtr).FullStringLengthInBytes)) = .Detail(lCtr).FullString) Then
-
- bFound = True
- If .Detail(lCtr).EquivalentUpperCasePresent Then
- If Len(sPreviousCharacter$) = 0 Then
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- Else
- LocalMarcCharacter.Utf8Char = sPreviousCharacter$
-
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- sOut$ = sOut$ + .Detail(lCtr).EquivalentUpperCase
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- End If
- bChanged = True
- iLen% = .Detail(lCtr).FullStringLengthInBytes
- Else
- If bFirstCharacterIsUppercase Then
- sOut$ = sOut$ + LocalMarcRecordObject.UCaseFirstWord(.Detail(lCtr).Equivalent)
- bFirstCharacterIsUppercase = False
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- bChanged = True
- iLen% = .Detail(lCtr).FullStringLengthInBytes
- End If
- Exit For
- End If
- Else
- If ReRomanizeTextDetailsReplaceApostrophes(LocalMarcRecordObject.SafeLCase(LocalMarcRecordObject.SafeMid(sText, lPtr, .Detail(lCtr).FullStringLengthInCharacters)), iRomanizationTable%, LocalMarcCharacter, iLengthBeforeApostropheSubstitution%) = .Detail(lCtr).FullString Then
- bFound = True
- If .Detail(lCtr).EquivalentUpperCasePresent Then
- If Len(sPreviousCharacter$) = 0 Then
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- Else
- LocalMarcCharacter.Utf8Char = sPreviousCharacter$
-
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- sOut$ = sOut$ + .Detail(lCtr).EquivalentUpperCase
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- End If
- iLen% = iLengthBeforeApostropheSubstitution%
- Else
- If bFirstCharacterIsUppercase Then
- sOut$ = sOut$ + LocalMarcRecordObject.UCaseFirstWord(.Detail(lCtr).Equivalent)
- bFirstCharacterIsUppercase = False
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- iLen% = iLengthBeforeApostropheSubstitution%
- End If
- Exit For
- End If
- End If
- End If
- Else
-
- sOut$ = LocalMarcRecordObject.SafeStuff(sOut$, lPtr + lPtr2, 0, LocalMarcRecordObject.MarcRightToLeftMarker)
- End If
-
- If Mid(sOut$, lPtr + 1, 1) <> "6" Then
- sOut$ = LocalMarcRecordObject.SafeStuff(sOut$, lPtr + 2, 0, LocalMarcRecordObject.MarcRightToLeftMarker)
- End If
-
- Exit Do
- End If
- Loop
-
- If lPtr > 1 Then
- sOut$ = Mid(sText$, 1, lPtr - 1)
- End If
-
-
-
- Do While lPtr <= lEnd
-
-
-
- iLen% = 0
-
- For lPtr2 = lPtr + 1 To lEnd
- If InStr("- .;:)([]!?" + Chr(34) + LocalMarcRecordObject.MarcDelimiter, Mid(sText, lPtr2, 1)) > 0 Then
- iLen% = lPtr2 - lPtr
- Exit For
- End If
- Next
-
-
- If iLen% = 0 Then
- iLen% = Len(Mid(sText$, lPtr))
- End If
- sSyllable$ = Mid(sText, lPtr, iLen%)
- If Right(sSyllable$, 1) = "'" Then
- iLen% = iLen% - 1
- lPtr2 = lPtr2 - 1
- sSyllable$ = Mid(sSyllable$, 1, Len(sSyllable$) - 1)
- End If
- sOriginalSyllable$ = sSyllable$
-
-
-
-
- #If True Then
-
-
- If sSyllable$ = LocalMarcRecordObject.SafeUCase(sSyllable$) Then
-
- bWholeThingIsUppercase = True
- bFirstCharacterIsUppercase = False
- If gblaRomanizationTable(iRomanizationTable%).AllowCaseVariation Then
- sSyllable$ = LocalMarcRecordObject.SafeLCase(sSyllable$)
- End If
- ElseIf sSyllable$ = LocalMarcRecordObject.SafeLCase(sSyllable$) Then
- bWholeThingIsUppercase = False
- bFirstCharacterIsUppercase = False
- Else
-
-
-
- bWholeThingIsUppercase = False
- bFirstCharacterIsUppercase = True
- If gblaRomanizationTable(iRomanizationTable%).AllowCaseVariation Then
- sSyllable$ = LocalMarcRecordObject.SafeLCase(sSyllable$)
- End If
- End If
- LocalMarcCharacter.Utf8Char = sSyllable$
- #Else
-
- LocalMarcCharacter.Utf8Char = sSyllable$
- If gblaRomanizationTable(iRomanizationTable%).AllowCaseVariation Then
- If LocalMarcCharacter.Utf8CharCategory = "Lu" Then
- bFirstCharacterIsUppercase = True
- bWholeThingIsUppercase = True
- Do
- sSyllable$ = Mid(sSyllable$, LocalMarcCharacter.Utf8CharOctets + 1)
- If Len(sSyllable$) = 0 Then
- Exit Do
- End If
-
- bWholeThingIsUppercase = False
- Exit Do
- End If
- Loop
-
- sSyllable$ = Mid(sText, lPtr, iLen%)
- LocalMarcCharacter.Utf8Char = sSyllable$
- End If
-
-
- sSyllable$ = LocalMarcRecordObject.SafeLCase(sSyllable$)
- LocalMarcCharacter.Utf8Char = sSyllable$
- End If
- #End If ' alternative methods for determining casing of the existing syllable
-
-
- If bApostrophes Then
- sSyllable$ = ReRomanizeTextDetailsReplaceApostrophes(sSyllable$, iRomanizationTable%, LocalMarcCharacter, iLengthBeforeApostropheSubstitution%)
- End If
-
- bFound = False
- If oRomanizationTable.Exists(LocalMarcCharacter.Utf8Char) Then
- lMember = oRomanizationTable.item(LocalMarcCharacter.Utf8Char)
- With RomanizationTable(lMember)
- For lCtr = 1 To .DetailLast
- If bRoman2Vernacular Then
- If sSyllable$ = .Detail(lCtr).FullString Then
- bFound = True
- If bWholeThingIsUppercase Then
- sOut$ = sOut$ + LocalMarcRecordObject.SafeUCase(.Detail(lCtr).Equivalent)
- bFirstCharacterIsUppercase = False
- ElseIf bFirstCharacterIsUppercase Then
- sOut$ = sOut$ + LocalMarcRecordObject.UCaseFirstWord(.Detail(lCtr).Equivalent)
- bFirstCharacterIsUppercase = False
- Else
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- End If
- Exit For
- End If
- Else
- If sSyllable$ = .Detail(lCtr).FullString Then
- bFound = True
- sOut$ = sOut$ + .Detail(lCtr).Equivalent
- Exit For
- End If
- End If
- Next
- End With
- Else
- sSyllable$ = sOriginalSyllable$
- bFound = False
- End If
- If Not bFound Then
- sOut$ = sOut$ + sSyllable$
- End If
-
-
- lPtr = lPtr + iLen%
- If lPtr > lEnd Then
-
- Exit Do
- End If
-
-
- Do
- Select Case Mid(sText$, lPtr, 1)
- Case "-", " ", ".", ";", ":", "(", ")", "[", "]", "!", "?", "'", Chr(34)
- sOut$ = sOut$ + Mid(sText$, lPtr, 1)
- lPtr = lPtr + 1
- If lPtr > lEnd Then
- Exit Do
- End If
- Case LocalMarcRecordObject.MarcDelimiter
- sOut$ = sOut$ + Mid(sText$, lPtr, 2)
- lPtr = lPtr + 2
- If lPtr > lEnd Then
- Exit Do
- End If
- Case Else
- Exit Do
- End Select
- Loop
- If lPtr > lEnd Then
- Exit Do
- End If
-
- Loop
-
- End If
-
-
-
- ReRomanizeTextDetails = sOut$
-
- End Function
- Public Function EvaluateFirstCharacter(ByVal sText$, ByVal iRomanizationTable%, ByRef LocalMarcCharacter As Utf8CharClass) As Integer
- Dim lPtr As Long, lLength As Long
-
- Dim iLength%
-
-
- EvaluateFirstCharacter = ROMANIZATIONDIRECTION_Unknown%
-
- If iRomanizationTable% < 1 Or iRomanizationTable% > gbliRomanizationTableLast% Then
-
- Else
- With gblaRomanizationTable(iRomanizationTable%)
-
-
-
- lPtr = 1
- lLength = Len(sText$)
- Do While lPtr <= lLength
- LocalMarcCharacter.Utf8Char = Mid(sText$, lPtr)
- If LocalMarcCharacter.Utf8Char = LocalMarcCharacter.MarcDelimiter Then
-
-
- iLength% = 2
- Else
- iLength% = LocalMarcCharacter.Utf8CharOctets
- #If EvaluateFirstCharacterDebug = -1 Then
- Debug.Print "Char: >" + LocalMarcCharacter.Utf8Char + "< " + str(iLength%)
- #End If
- If .Roman2Vernacular.Exists(LocalMarcCharacter.Utf8Char) Then
- EvaluateFirstCharacter = ROMANIZATIONDIRECTION_Roman2Vernacular%
- Exit Do
- ElseIf .Vernacular2Roman.Exists(LocalMarcCharacter.Utf8Char) Then
- EvaluateFirstCharacter = ROMANIZATIONDIRECTION_Vernacular2Roman%
- Exit Do
- End If
- End If
- lPtr = lPtr + iLength%
- Loop
- End With
- End If
-
- End Function
- Public Function ReRomanizeTextDetailsReplaceApostrophes(ByVal sString$, ByVal iRomanizationTable%, ByRef LocalCharacterObject As Utf8CharClass, ByRef iLengthBeforeApostropheSubstitution%) As String
- Dim lPtr As Long
-
- Dim iLen%
-
- Dim sSaveIncomingCharacter$, sOut$
-
-
- sOut$ = sOut$ + "'"
- Else
- sOut$ = sOut$ + LocalCharacterObject.Utf8Char
- End If
- lPtr = lPtr + LocalCharacterObject.Utf8CharOctets
- Loop
- LocalCharacterObject.Utf8Char = sSaveIncomingCharacter$
- End If
- ReRomanizeTextDetailsReplaceApostrophes = sOut$
-
- If sSubfield6Code$ = CHARACTERSET_CODES_FOR_880_HebrewAsG0$ Or _
- sSubfield6Code$ = CHARACTERSET_CODES_FOR_880_BasicArabicAsG0$ Then
-
- sSubfield6Code$ = sSubfield6Code$ & "/r"
- End If
-
- sSubfield6Code$ = "/" + sSubfield6Code$
- End If
- End If
- If gblaRomanizationTable(iScript%).R2VIncludeFormattingCharactersLcPattern Or _
- InStr(sSubfield6Code$, "/r") > 0 Then
-
-
-
-
-
-
- bLcPattern = True
-
-
-
- With LocalMarcRecordObjectAlreadyLoadedWithRecord
- sRLM$ = .MarcRightToLeftMarker
- sLRE$ = .MarcLeftToRightEmbedding
- sPDF$ = .MarcPopDirectionalFormatting
- End With
- Else
-
-
-
-
-
-
- bLcPattern = False
- End If
-
- sType$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcRecordFormat
-
-
- RomanizationAssistance = ROMANIZATIONRESULT_Success%
-
- Select Case iAction
- Case ROMANIZATIONACTION_RomanizeHighlightedText%, ROMANIZATIONACTION_LCaseWord%, ROMANIZATIONACTION_UCaseWord%, ROMANIZATIONACTION_ReplaceText%, ROMANIZATIONACTION_UCaseEach%, ROMANIZATIONACTION_Define%
-
-
- If gblaRomanizationTable(iScript%).NoRomanization Then
- If iAction = ROMANIZATIONACTION_Define% Then
- GoTo RomanizationAssistanceNoFileOpenResume
- End If
- End If
-
-
-
-
-
-
- sField$ = LocalRichTextBox.SelRTF
-
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sField$, "\'87", "\u8225?")
-
-
- If InStr(sField$, "\f0 ") Or InStr(sField$, "\f1 ") Then
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sField$, "\f0 "), "\f1 ")
- ElseIf InStr(sField$, "\f0") Or InStr(sField$, "\f1") Then
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sField$, "\f0"), "\f1")
- End If
-
- sField$ = Trim(Mid(sField$, iRc% + 2))
- End If
-
-
- Do While Mid(sField$, 1, 1) = "\"
- If Mid(sField$, 1, 2) = "\u" Then
- If InStr("0123456789", Mid(sField$, 3, 1)) > 0 Then
- Exit Do
- End If
- End If
- sField$ = Mid(sField$, 2)
- iRc% = InStr(sField$, "\")
- If iRc% = 0 Then
- iRc% = InStr(sField$, " ")
- If iRc% > 0 Then
- sField$ = Mid(sField$, iRc% + 1)
- Exit Do
- End If
- Else
- iRc2% = InStr(sField$, " ")
- If iRc2% > 0 Then
- If iRc% < iRc2% Then
- sField$ = Mid(sField$, iRc%)
- Else
- sField$ = Mid(sField$, iRc2% + 1)
- Exit Do
- End If
- Else
- sField$ = Mid(sField$, iRc%)
- End If
- End If
- Loop
-
- iRc% = LocalMarcRecordObjectAlreadyLoadedWithRecord.Rat(sField$, "\par")
- If iRc% > 0 Then
- sField$ = Mid(sField$, 1, iRc% - 1)
- End If
- If Len(sField$) = 0 Then
- RomanizationAssistance = ROMANIZATIONRESULT_HighlightedTextBecomesNothing%
- Exit Function
- End If
-
- sField$ = Trim(sField$)
-
-
-
-
-
-
-
-
-
-
-
-
- sFieldRemainderLeft$ = Mid(LocalRichTextBox.Text, 1, lSelStart)
- lPtr = LocalMarcRecordObjectAlreadyLoadedWithRecord.Rat(sFieldRemainderLeft$, vbLf)
- If lPtr > 0 Then
- sFieldRemainderLeft$ = Trim(Mid(sFieldRemainderLeft$, lPtr + 1) + sField$)
- sTagToFind$ = Mid(sFieldRemainderLeft$, 1, 3)
- Else
- RomanizationAssistance = ROMANIZATIONRESULT_TextNotFindable%
- Exit Function
- End If
-
- Select Case LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcRecordFormat
- Case "A"
- sNonfilingString$ = sAuthorityNonfilingString$
- Case "B", "D", "F", "M", "P", "S", "U"
- sNonfilingString$ = sBibliographicNonfilingString$
-
- End Select
-
-
-
-
-
- sRecord$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfText)
- lStart = 1
- Do
-
- lSelStart = InStr(lStart, sRecord$, sField$)
- DoEvents
- If lSelStart = 0 Then
- If lStart = 1 Then
- RomanizationAssistance = ROMANIZATIONRESULT_TextNotFindable%
- Exit Function
- End If
-
-
- lSelStart = InStr(1, sRecord$, sField$)
- If lSelStart = 0 Then
- RomanizationAssistance = ROMANIZATIONRESULT_TextNotFindable%
- Exit Function
- End If
- bSkipTagTest = True
- Else
- lStart = lSelStart + 1
- End If
- sLeft$ = Mid(sRecord$, 1, lSelStart - 1)
- sRight$ = Mid(sRecord$, lSelStart + Len(sField$))
-
-
-
- lSelStart = LocalMarcRecordObjectAlreadyLoadedWithRecord.Rat(sLeft$, sLineEnd$)
- If lSelStart > 0 Then
- sFieldRemainderLeft$ = LTrim(Mid(sLeft$, lSelStart + 5))
- If Mid(sFieldRemainderLeft$, 1, 2) = "\f" Then
- sLeft$ = sLeft$ + Mid(sFieldRemainderLeft$, 1, 4)
- sFieldRemainderLeft$ = Mid(sFieldRemainderLeft$, 5)
- End If
- Else
- sFieldRemainderLeft$ = ""
- End If
- If Mid(LTrim(sFieldRemainderLeft$ + sField$), 1, 3) = sTagToFind$ Or bSkipTagTest Then
-
-
- lSelStart = InStr(sRight$, sLineEnd$)
- If lSelStart > 1 Then
- sFieldRemainderRight$ = Mid(sRight$, 1, lSelStart - 1)
- Else
- sFieldRemainderRight$ = ""
- End If
- sFieldRemainderLeft$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.TranslateRTF2Marc(sFieldRemainderLeft$)
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.RemoveSpacesAroundDelimiters(LocalMarcRecordObjectAlreadyLoadedWithRecord.TranslateRTF2Marc(sField$))
- sFieldRemainderRight$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.TranslateRTF2Marc(sFieldRemainderRight$)
- sWholeField$ = Trim(sFieldRemainderLeft$ + sField$ + sFieldRemainderRight$)
- Exit Do
- End If
- Loop
-
- Select Case iAction
-
- Case ROMANIZATIONACTION_RomanizeHighlightedText%
- sTag$ = Mid(sWholeField$, 1, 3)
- sIndicators$ = Mid(sWholeField$, 5, 2)
- sWholeField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.RemoveSpacesAroundDelimiters(Trim(Mid(sWholeField$, 8)))
- If Mid(sWholeField$, 1, 2) = "\f" Then
- sWholeField$ = Mid(sWholeField$, 4)
- End If
- RA_WeHaveOurFieldTheEasyWay:
-
-
- If gblaRomanizationTable(iScript%).NoRomanization Then
-
-
- GoTo RomanizationAssistanceNoFileOpenResume
- End If
- s6$ = Mid(sWholeField$, iRc% + 2)
- iRc% = InStr(s6$, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter)
- If iRc% > 0 Then
- s6$ = Mid(s6$, 1, iRc% - 1)
- End If
- Else
-
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveTop
- Do While LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveNext
- If LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdFindFirst("6") Then
- iRc% = InStr(LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, "-")
- If iRc% > 0 Then
- iRepeat% = Val(Trim(Mid(LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, iRc% + 1)))
- If iRepeat% > iNext6% Then
- iNext6% = iRepeat%
- End If
- End If
- End If
- Loop
- iNext6% = iNext6% + 1
-
- If gblaRomanizationTable(iScript%).NoRomanization Then
-
-
-
-
-
- bFound = False
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveTop
- Do While LocalMarcRecordObjectAlreadyLoadedWithRecord.FldFindNext(sTag$)
- If LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sWholeField$ Then
- lFldPointer = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
- bFound = True
- End If
- Loop
- If Not bFound Then
- RomanizationAssistance = ROMANIZATIONRESULT_FieldNotFound%
- Exit Function
- End If
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- sTag$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag
- sIndicators$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldInd
-
- If sTag$ >= 600 And sTag$ <= 651 Then
- s880Indicators$ = Mid$(sIndicators$, 1, 1) & "4"
- Else
- s880Indicators$ = sIndicators$
- End If
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveFirst
-
- bOnlyMarc8 = LocalMarcRecordObjectAlreadyLoadedWithRecord.Utf8TextContainsOnlyMarc8Characters(sField$)
-
-
-
-
-
- With LocalMarcRecordObjectAlreadyLoadedWithRecord
- .FldDelete
- .FldAdd .FldTag, .FldInd, .MarcDelimiter + "6" + "880-" + Right("00" + Trim(str(iNext6%)), 2) + sField$
- End With
-
-
- lFldPointer = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
-
-
-
-
-
- With LocalMarcRecordObjectAlreadyLoadedWithRecord
- .FldAdd .FldTag, .FldInd, .MarcDelimiter + "6" + sTag$ + "-" + Right("00" + Trim(str(iNext6%)), 2) + sField$
- End With
- lFldPointer2 = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
-
- If bOnlyMarc8 Then
-
-
-
-
- If gblaRomanizationTable(iScript%).R2VCreateEmpty880s Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer2
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveFirst
- Do While True
- If InStr("68", LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode) = 0 Then
-
-
-
-
- If bLcPattern Then
-
-
-
-
- If sTag$ Like "26[04]" And LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode = "c" Then
-
- If Right(LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, 1) = "." Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText = sRLM$ + sLRE$ + "+" + sPDF$ + "."
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText = sRLM$ + sLRE$ + "+" + sPDF$
- End If
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText = sRLM$ + "+" + sRLM$
- End If
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText = "+"
- End If
- Else
-
- If bLcPattern Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText = LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText + sSubfield6Code$ + sRLM$
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText = LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText + sSubfield6Code$
- End If
- End If
- If Not LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveNext Then
-
- If bLcPattern And Right(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText, 3) = sRLM$ Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = Left(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText, Len(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText) - 3)
- End If
- Exit Do
- End If
- Loop
- End If
- Else
-
-
-
-
- If gblaRomanizationTable(iScript%).V2RCreateEmptyFields Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveFirst
- sField$ = ""
- Do While True
- If InStr("68", LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode) = 0 Then
-
- sField$ = sField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode + "+"
- Else
- sField$ = sField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText
- End If
- If Not LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveNext Then
- Exit Do
- End If
- Loop
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sField$
- End If
- End If
- GoTo RomanAssist_DisplayTheFinishedRecord
- End If
- End If
-
- iRomanizationStyle% = EvaluateFirstCharacter(sField$, iScript%, LocalMarcCharacterObject)
- If iRomanizationStyle% = ROMANIZATIONDIRECTION_Unknown% Then
- RomanizationAssistance = ROMANIZATIONRESULT_ActionUnclear%
- Exit Function
- End If
-
-
-
-
-
-
-
-
- If sTag$ <> "880" Then
- If Len(s6$) = 0 Then
-
-
- bFound = False
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveTop
- Do While LocalMarcRecordObjectAlreadyLoadedWithRecord.FldFindNext(sTag$)
-
- RomanAssist_ReplayWithSubstitution:
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldLoadInfo sTagToCopy$, sIndicatorsToCopy$, sFieldToCopy$
- lFldPointer2 = lFldPointer
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldAdd "880", sIndicatorsToCopy$, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + sTagToCopy$ + "-" + Right("00" + Trim(str(iNext6%)), 2) + sSubfield6Code$ + sFieldToCopy$
-
-
- lFldPointer = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
-
-
- sLeft$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6880-" + Right("00" + Trim(str(iNext6%)), 2) + Mid(sWholeField$, 1, iRc% - 1)
- If Right(sLeft$, 1) = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter Then
- sLeft$ = Mid(sLeft$, 1, Len(sLeft$) - 1)
- sIntermediate$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter
- ElseIf Mid(Right(sLeft$, 2), 1, 1) = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter Then
- sIntermediate$ = Right(sLeft$, 2)
- sLeft$ = Mid(sLeft$, 1, Len(sLeft$) - 2)
- End If
- sRight$ = Mid(sWholeField$, iRc% + Len(sField$))
- sField$ = sIntermediate$ + sField$
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer2
- If Right(sField$, 1) = " " Then
- bStringHasTerminalSpace = True
- Else
- bStringHasTerminalSpace = False
- End If
-
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.UCaseFirstWord(ReRomanizeText(sType$, LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag, sField$, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject))
- If Not bStringHasTerminalSpace Then
- sField$ = RTrim(sField$)
- End If
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sLeft$ + sField$ + sRight$
-
- lFldPointer2 = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
-
-
- #If RomanizationAssistanceDebug = -1 Then
- Debug.Print "Adjust NON #1"
- #End If
- ReRomanizeAdjustNonfilingIndicators iScript%, sNonfilingString$, lFldPointer, lFldPointer2, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject
-
- GoTo RomanAssist_DisplayTheFinishedRecord
-
- Else
- iRc% = InStr(sField$, sWholeField$)
- If iRc% > 0 Then
- sField$ = sWholeField$
- iRc% = InStr(sWholeField$, sField$)
- If iRc% > 0 Then
- GoTo RomanAssist_ReplayWithSubstitution
- End If
- End If
-
- End If
- Else
-
-
- iRc% = InStr(sWholeField$, sField$)
- If iRc% > 0 Then
- RomanAssist_ReplayWithSubstitution2:
-
- sRight$ = Mid(sWholeField$, iRc% + Len(sField$))
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- sTagToCopy$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag
- If gblaRomanizationTable(iScript%).DoNotUse880Field Then
-
- sLeft$ = Mid(sWholeField$, 1, iRc% - 1)
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sLeft$ + ReRomanizeText(sType$, LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag, sField$, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject) + sRight$
- Else
- sLeft$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + sTag$ + "-" + Right("00" + Trim(str(iNext6%)), 2) + sSubfield6Code$ + Mid(sWholeField$, 1, iRc% - 1)
-
-
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldDelete
-
-
-
-
-
-
-
-
-
-
-
-
- If LenB(gblaRomanizationTable(iScript%).R2VVowelMarker) > 0 Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText, gblaRomanizationTable(iScript%).R2VVowelMarker)
- End If
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldInsertAfter sTagToCopy$, sIndicators$, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + "880-" + Right("00" + Trim(str(iNext6%)), 2) + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText
-
- lFldPointer = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
-
- sField$ = ReRomanizeText(sType$, sTagToCopy$, sField$, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject)
-
- If bLcPattern Then
- lPtr = InStr(sLeft$, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6")
- If lPtr > 0 Then
- sLeft$ = sLeft$ & LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcRightToLeftMarker
- End If
-
-
-
- lPtr2 = InStr(sField$, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "c")
- If lPtr2 <> 0 And sTagToCopy$ Like "26[04]" Then
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeStuff(sField$, lPtr2 + 5, 0, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcLeftToRightEmbedding)
-
- If Right(sField$, 1) = "." Then
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeStuff(sField$, InStrRev(sField$, "."), 1, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcPopDirectionalFormatting + ".")
- Else
- sField$ = sField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcPopDirectionalFormatting
- End If
- End If
- End If
-
-
-
-
-
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldInsertAfter "880", s880Indicators$, sLeft$ + sField$ + sRight$
-
- lFldPointer2 = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
-
- #If RomanizationAssistanceDebug = -1 Then
- Debug.Print "Adjust NON #2"
- #End If
- ReRomanizeAdjustNonfilingIndicators iScript%, sNonfilingString$, lFldPointer, lFldPointer2, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- End If
- GoTo RomanAssist_DisplayTheFinishedRecord
- Else
- iRc% = InStr(sField$, sWholeField$)
- If iRc% > 0 Then
- sField$ = sWholeField$
- iRc% = InStr(sWholeField$, sField$)
- If iRc% > 0 Then
- GoTo RomanAssist_ReplayWithSubstitution2
- End If
- End If
-
- End If
- End If
- Else
- If iRomanizationStyle% = ROMANIZATIONDIRECTION_Vernacular2Roman% Then
-
-
-
-
- RomanAssist_ReRomanizeInPlace:
- bFound = False
- sTag$ = Mid(sFieldRemainderLeft$, 1, 3)
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveTop
- Do While LocalMarcRecordObjectAlreadyLoadedWithRecord.FldFindNext(sTag$)
- If LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sWholeField$ Then
- lFldPointer = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
- bFound = True
- End If
- Loop
- If Not bFound Then
- RomanizationAssistance = ROMANIZATIONRESULT_FieldNotFound%
- Exit Function
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- If Len(sFieldRemainderLeft$) > 0 Then
- lFldPointer = InStr(sFieldRemainderLeft$, LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter)
- If lFldPointer > 0 Then
- sFieldRemainderLeft$ = Mid(sFieldRemainderLeft$, lFldPointer)
- End If
- End If
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sFieldRemainderLeft$ + ReRomanizeText(sType$, LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag, sField$, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject) + sFieldRemainderRight$
- GoTo RomanAssist_DisplayTheFinishedRecord
- End If
- Else
-
-
-
- End If
- End If
- Else
-
- If Len(s6$) = 0 Then
- RomanizationAssistance = ROMANIZATIONRESULT_880WithNoSubfield6%
- Exit Function
- Else
-
- GoTo RomanAssist_ReRomanizeInPlace
- End If
- End If
-
- Case ROMANIZATIONACTION_LCaseWord%, ROMANIZATIONACTION_UCaseWord%, ROMANIZATIONACTION_ReplaceText%, ROMANIZATIONACTION_UCaseEach%, ROMANIZATIONACTION_Define%
- sTag$ = Mid(sWholeField$, 1, 3)
- sIndicators$ = Mid(sWholeField$, 5, 2)
- sWholeField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.RemoveSpacesAroundDelimiters(Trim(Mid(sWholeField$, 8)))
- If Mid(sWholeField$, 1, 2) = "\f" Then
- sWholeField$ = Mid(sWholeField$, 4)
- End If
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveTop
- Do While LocalMarcRecordObjectAlreadyLoadedWithRecord.FldFindNext(sTag$)
- If LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sWholeField$ Then
- lFldPointer = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer
- bFound = True
- End If
- Loop
- If Not bFound Then
- RomanizationAssistance = ROMANIZATIONRESULT_FieldNotFound%
- Exit Function
- End If
-
- iRc% = InStr(sWholeField$, sField$)
- If iRc% > 0 Then
-
- iRc% = InStr(sWholeField$, sField$)
- If iRc% > 0 Then
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = lFldPointer
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldLoadInfo sTagToCopy$, sIndicatorsToCopy$, sFieldToCopy$
-
- sLeft$ = Mid(sWholeField$, 1, iRc% - 1)
- If Right(sLeft$, 1) = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter Then
- sLeft$ = Mid(sLeft$, 1, Len(sLeft$) - 1)
- sIntermediate$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter
- ElseIf Mid(Right(sLeft$, 2), 1, 1) = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter Then
- sIntermediate$ = Right(sLeft$, 2)
- sLeft$ = Mid(sLeft$, 1, Len(sLeft$) - 2)
- End If
- sRight$ = Mid(sWholeField$, iRc% + Len(sField$))
- sField$ = sIntermediate$ + sField$
- sOriginalField$ = sField$
-
- Select Case iAction
- Case ROMANIZATIONACTION_LCaseWord%
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sLeft$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.LCaseFirstWord(sField$) + sRight$
- Case ROMANIZATIONACTION_UCaseWord%
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sLeft$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.UCaseFirstWord(sField$) + sRight$
- Case ROMANIZATIONACTION_ReplaceText%, ROMANIZATIONACTION_Define%
- sNewField$ = ""
- sOriginalLeft$ = sLeft$
- sOriginalRight$ = sRight$
-
- Do While Len(sField$) > 0
- If Asc(Mid(sField$, 1, 1)) > 127 Then
- LocalMarcCharacterObject.Utf8Char = sField$
- sField$ = Mid(sField$, LocalMarcCharacterObject.Utf8CharOctets + 1)
- sNewField$ = sNewField$ + "{U+" + LocalMarcCharacterObject.UcsHex + "}"
- Else
- sNewField$ = sNewField$ + Mid(sField$, 1, 1)
- sField$ = Mid(sField$, 2)
- End If
- Loop
- If iAction = ROMANIZATIONACTION_Define% Then
- sFile$ = gblaRomanizationTable(iScript%).FullFileName
- sTempFile$ = sFile$
- iRc2% = LocalMarcRecordObjectAlreadyLoadedWithRecord.Rat(sTempFile$, "\")
- If iRc2% = 0 Then
- Exit Function
- End If
- sTempFile$ = Mid(sTempFile$, 1, iRc2%) + "Temp.$$$"
- On Error GoTo RomanizationAssistanceNoFileOpen
- iOut% = FreeFile
- Open sTempFile$ For Output As #iOut%
- On Error GoTo 0
- iIn% = FreeFile
- Open sFile$ For Input As #iIn%
-
- iRc% = InStr(sNewField$, "{U+")
- If iRc% = 0 Then
- RomanizationAssistance = ROMANIZATIONRESULT_NoCharacterToDefine%
- Exit Function
- End If
-
-
- sField$ = InputBox("Please supply the replacement text for U+" + Mid(sNewField$, iRc% + 3, 4) + ". (Supply empty text to cancel.)", "Define replacement for vernacular character", "")
- If Len(sField$) = 0 Then
- Close #iIn%
- Close #iOut%
- Exit Function
- End If
-
-
- If sField$ = Mid(sNewField$, iRc% + 3, 4) Then
- Close #iIn%
- Close #iOut%
- Exit Function
- End If
-
-
-
-
-
-
-
-
-
-
-
-
- sField$ = Trim(sField$) & " "
- Do While Not EOF(iIn%)
- DoEvents
- Line Input #iIn%, sLine$
- Print #iOut%, sLine$
-
-
-
-
- If sLine$ = "[ScriptToRoman]" Then
- Print #iOut%, "U+" + Mid(sNewField$, iRc% + 3, 4) + "=" + LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sField$, " ", "_")
- End If
- Loop
- Close #iIn%
- Close #iOut%
- On Error GoTo RomanizationAssistanceBadKill
- Kill sFile$
- DoEvents
- FileCopy sTempFile$, sFile$
- DoEvents
- Kill sTempFile$
-
-
-
-
-
-
- sNewCharacter$ = RomanizeConvertText("U+" + Mid(sNewField$, iRc% + 3, 4), LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject)
- LocalMarcCharacterObject.UcsHex = Mid(sNewField$, iRc% + 3, 4)
- If gblaRomanizationTable(iScript%).Vernacular2Roman.Exists(LocalMarcCharacterObject.Utf8Char) Then
- iElement% = gblaRomanizationTable(iScript%).Vernacular2Roman.item(LocalMarcCharacterObject.Utf8Char)
- Else
- gblaRomanizationTable(iScript%).VernacularLast = gblaRomanizationTable(iScript%).VernacularLast + 1
- If gblaRomanizationTable(iScript%).VernacularLast > gblaRomanizationTable(iScript%).VernacularMax Then
- gblaRomanizationTable(iScript%).VernacularMax = gblaRomanizationTable(iScript%).VernacularMax + 10
- ReDim Preserve gblaRomanizationTable(iScript%).Vernacular(0 To gblaRomanizationTable(iScript%).VernacularMax)
- End If
- iElement% = gblaRomanizationTable(iScript%).VernacularLast
- gblaRomanizationTable(iScript%).Vernacular2Roman.Add LocalMarcCharacterObject.Utf8Char, iElement%
- End If
- gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast = gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast + 1
- If gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast > gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailMax Then
- gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailMax = gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailMax + 5
- ReDim Preserve gblaRomanizationTable(iScript%).Vernacular(iElement%).Detail(0 To gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailMax)
- End If
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sField$, "_", " ")
- gblaRomanizationTable(iScript%).Vernacular(iElement%).Detail(gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast).FullStringLengthInCharacters = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeLen(sNewCharacter$)
- gblaRomanizationTable(iScript%).Vernacular(iElement%).Detail(gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast).FullStringLengthInBytes = Len(sNewCharacter$)
- gblaRomanizationTable(iScript%).Vernacular(iElement%).Detail(gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast).FullString = sNewCharacter$
- gblaRomanizationTable(iScript%).Vernacular(iElement%).Detail(gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast).Equivalent = sField$
- gblaRomanizationTable(iScript%).Vernacular(iElement%).Detail(gblaRomanizationTable(iScript%).Vernacular(iElement%).DetailLast).EquivalentUpperCasePresent = False
-
- Select Case Mid(sOriginalField$, iRc% + Len(sNewCharacter$), 1)
- Case " "
- sOriginalField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeStuff(sOriginalField$, iRc%, Len(sNewCharacter$), sField$)
- Case Chr(34), "'", ";", ":", ",", ".", "/", "<", ">", "?", "[", "]", "\", "{", "}", "|", "-", "=", "!", "@", "#", "$%", "^", "&", "*", "(", ")", "_", "+", ""
- sOriginalField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeStuff(sOriginalField$, iRc%, Len(sNewCharacter$), Trim(sField$))
- Case Else
- sOriginalField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeStuff(sOriginalField$, iRc%, Len(sNewCharacter$), sField$)
- End Select
- iRc% = InStr(sOriginalField$, sNewCharacter$)
- Loop
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = LocalMarcRecordObjectAlreadyLoadedWithRecord.RemoveRepeatedCharacters(sOriginalField$, " ")
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = LocalMarcRecordObjectAlreadyLoadedWithRecord.RemoveRepeatedCharacters(LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sOriginalLeft$ + sOriginalField$ + sOriginalRight$, sNewCharacter$, sField$), " ")
- End If
- Else
- sNewField$ = InputBox("Please supply the replacement text. Non-ASCII characters are shown as Unicode(TM) values within curly braces." + vbLf + "Original: " + sNewField$, "Replace text", sNewField$)
- If Len(sNewField$) > 0 Then
- Do
- iRc% = InStr(sNewField$, "{U+")
- If iRc% = 0 Then
- Exit Do
- End If
- sLeft2$ = Mid(sNewField$, 1, iRc% - 1)
- sNewField$ = Mid(sNewField$, iRc% + 3)
- iRc% = InStr(sNewField$, "}")
- If iRc% > 1 Then
- sRight2$ = Mid(sNewField$, iRc% + 1)
- LocalMarcCharacterObject.UcsHex = Mid(sNewField$, 1, iRc% - 1)
- sNewField$ = LocalMarcCharacterObject.Utf8Char
- Else
- sRight2$ = ""
- End If
- sNewField$ = sLeft2$ + sNewField$ + sRight2$
- Loop
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sLeft$ + sNewField$ + sRight$
- End If
- End If
- Case ROMANIZATIONACTION_UCaseEach%
- sNewField$ = ""
- Do While Len(sField$) > 0
- GetNextPiece sField$, sWord$, " "
- sNewField$ = Trim(sNewField$ + " " + LocalMarcRecordObjectAlreadyLoadedWithRecord.UCaseFirstWord(sWord$))
- Loop
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sLeft$ + sNewField$ + sRight$
- End Select
-
- GoTo RomanAssist_DisplayTheFinishedRecord
- End If
-
- End If
-
- End Select
-
- Case ROMANIZATIONACTION_RomanizeWholeRecord%
-
-
-
- iRc% = RomanizationAssistanceConvertWholeRecord(sType$, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject)
- If iRc% <> 0 Then
- RomanizationAssistance = iRc%
- Exit Function
- End If
-
- GoTo RomanAssist_DisplayTheFinishedRecord
-
- Case ROMANIZATIONACTION_DisplayMarcRecord%
-
- RomanAssist_DisplayTheFinishedRecord:
-
- If iFldTextFormattedOption% = 99 Then
- Select Case iFixedFieldDisplayConvention%
- Case 2
- LocalRichTextBox.TextRTF = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfText, OclcMonospaced, "", True, sRtfFontName$, iFontSizeForDisplay%)
- Case 1
- LocalRichTextBox.TextRTF = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfText, oclc, "", True, sRtfFontName$, iFontSizeForDisplay%)
- Case Else
- LocalRichTextBox.TextRTF = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfText, notis, "", True, sRtfFontName$, iFontSizeForDisplay%)
- End Select
- Else
- Select Case iFixedFieldDisplayConvention%
- Case 2
- LocalRichTextBox.TextRTF = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfTextwithlabels, OclcMonospaced, "", True, sRtfFontName$, iFontSizeForDisplay%)
- Case 1
- LocalRichTextBox.TextRTF = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfTextwithlabels, oclc, "", True, sRtfFontName$, iFontSizeForDisplay%)
- Case Else
- LocalRichTextBox.TextRTF = LocalMarcRecordObjectAlreadyLoadedWithRecord.TextFormatted(rtfTextwithlabels, notis, "", True, sRtfFontName$, iFontSizeForDisplay%)
- End Select
- End If
-
- End Select
-
- RomanizationAssistanceNoFileOpenResume:
- Exit Function
-
- RomanizationAssistanceBadKill:
- RomanizationAssistanceNoFileOpen:
- RomanizationAssistance = ROMANIZATIONRESULT_FileOpen%
- On Error GoTo 0
- Resume RomanizationAssistanceNoFileOpenResume
-
- End Function
- Public Function FindFieldCurrentlyPointedTo(ByRef cRichTextBox As Control, ByRef LocalMarcRecord As Utf8MarcRecordClass, Optional ByVal bSearch As Boolean = False) As Long
-
-
-
-
-
-
-
- Dim lSelStart As Long, lOriginalSelStart As Long, lPtr As Long, lStart As Long
-
- Dim sField$, sRecord$, sFieldRemainderLeft$, sFieldRemainderRight$
- Dim sTagToFind$, sNonfilingString$
- Dim sLeft$, sRight$, sLineEnd$, sWholeField$
-
- Dim iRc%, iRc2%
-
- Dim bSkipTagTest As Boolean
-
-
-
- FindFieldCurrentlyPointedTo = -1
-
-
- lSelStart = cRichTextBox.SelStart
-
- If Len(cRichTextBox.SelText) > 0 Then
-
-
-
-
- lOriginalSelStart = lSelStart
- sField$ = cRichTextBox.SelRTF
- sRecord$ = cRichTextBox.TextRTF
-
-
- If Right(sField$, 1) = "}" Then
- sField$ = Mid(sField$, 1, Len(sField$) - 1)
- End If
-
- iRc% = InStr(sField$, "}}")
- If iRc% > 0 Then
- sField$ = Trim(Mid(sField$, iRc% + 2))
- End If
-
-
- Do While Mid(sField$, 1, 1) = "\"
- If Mid(sField$, 1, 2) = "\u" Then
- If InStr("0123456789", Mid(sField$, 3, 1)) > 0 Then
- Exit Do
- End If
- End If
- sField$ = Mid(sField$, 2)
- iRc% = InStr(sField$, "\")
- If iRc% = 0 Then
- iRc% = InStr(sField$, " ")
- If iRc% > 0 Then
- sField$ = Mid(sField$, iRc% + 1)
- Exit Do
- End If
- Else
- iRc2% = InStr(sField$, " ")
- If iRc2% > 0 Then
- If iRc% < iRc2% Then
- sField$ = Mid(sField$, iRc%)
- Else
- sField$ = Mid(sField$, iRc2% + 1)
- Exit Do
- End If
- Else
- sField$ = Mid(sField$, iRc%)
- End If
- End If
- Loop
-
- iRc% = LocalMarcRecord.Rat(sField$, "\par")
- If iRc% > 0 Then
- sField$ = Mid(sField$, 1, iRc% - 1)
- End If
-
- sField$ = Trim(sField$)
- If Len(sField$) = 0 Then
-
-
- GoTo FFCPT_UseJustSelStart
- End If
-
-
-
-
-
-
-
-
-
-
-
-
-
- sFieldRemainderLeft$ = Mid(cRichTextBox.Text, 1, lSelStart)
- lPtr = LocalMarcRecord.Rat(sFieldRemainderLeft$, vbLf)
- If lPtr > 0 Then
- sFieldRemainderLeft$ = Trim(Mid(sFieldRemainderLeft$, lPtr + 1) + sField$)
- sTagToFind$ = Mid(sFieldRemainderLeft$, 1, 3)
- Else
- GoTo FFCPT_UseJustSelStart
- End If
-
- Select Case LocalMarcRecord.MarcRecordFormat
- Case "A"
- sNonfilingString$ = sAuthorityNonfilingString$
- Case "B", "D", "F", "M", "P", "S", "U"
- sNonfilingString$ = sBibliographicNonfilingString$
-
- End Select
-
-
-
-
-
- sRecord$ = LocalMarcRecord.TextFormatted(rtfText, OclcMonospaced)
- lStart = 1
- Do
-
- lSelStart = InStr(lStart, sRecord$, sField$)
- DoEvents
- If lSelStart = 0 Then
- If lStart = 1 Then
- GoTo FFCPT_UseJustSelStart
- End If
-
-
- lSelStart = InStr(1, sRecord$, sField$)
- If lSelStart = 0 Then
- GoTo FFCPT_UseJustSelStart
- End If
- bSkipTagTest = True
- Else
- lStart = lSelStart + 1
- End If
- sLeft$ = Mid(sRecord$, 1, lSelStart - 1)
- sRight$ = Mid(sRecord$, lSelStart + Len(sField$))
-
-
-
- lSelStart = LocalMarcRecord.Rat(sLeft$, sLineEnd$)
- If lSelStart > 0 Then
- sFieldRemainderLeft$ = LTrim(Mid(sLeft$, lSelStart + 5))
- If Mid(sFieldRemainderLeft$, 1, 2) = "\f" Then
- sLeft$ = sLeft$ + Mid(sFieldRemainderLeft$, 1, 4)
- sFieldRemainderLeft$ = Mid(sFieldRemainderLeft$, 5)
- End If
- Else
- sFieldRemainderLeft$ = ""
- End If
- If Mid(LTrim(sFieldRemainderLeft$ + sField$), 1, 3) = sTagToFind$ Or bSkipTagTest Then
-
- FindFieldCurrentlyPointedTo = LocalMarcRecord.FldPointer
- Exit Function
- End If
-
- Loop
-
-
-
-
-
-
- End If
-
-
-
-
- FFCPT_UseJustSelStart:
-
-
-
-
-
-
-
-
-
-
-
-
- sLeft$ = Mid(cRichTextBox.Text, 1, lSelStart)
- sRight$ = Mid(cRichTextBox.Text, lSelStart + 1)
-
-
-
-
-
-
- lPtr = LocalMarcRecord.Rat(sLeft$, vbLf)
- If lPtr = 0 Then
- lPtr = LocalMarcRecord.Rat(sLeft$, vbCr)
- End If
- If lPtr > 0 Then
- sLeft$ = Mid(sLeft$, lPtr + 1)
- End If
-
-
- lPtr = InStr(sRight$, vbCr)
- If lPtr = 0 Then
- lPtr = LocalMarcRecord.Rat(sRight$, vbLf)
- End If
- If lPtr > 0 Then
- sRight$ = Mid(sRight$, 1, lPtr - 1)
- End If
-
-
- sField$ = Trim(sLeft$ + sRight$)
-
-
- If Len(sField$) = 0 Then
- Exit Function
- End If
-
- sTagToFind$ = Mid(sField$, 1, 3)
- If InStr("0123456789", Mid(sTagToFind$, 1, 1)) = 0 Or InStr("0123456789", Mid(sTagToFind$, 2, 1)) = 0 Or InStr("0123456789", Mid(sTagToFind$, 3, 1)) = 0 Then
- Exit Function
- End If
-
- If sTagToFind$ < "010" Then
- If Not bSearch Or (bSearch And sTagToFind$ <> "001") Then
- Exit Function
- End If
- End If
-
-
- LocalMarcRecord.FldMoveTop
- If Not LocalMarcRecord.FldFindFirst(sTagToFind$) Then
- Exit Function
- End If
-
-
-
- If Not LocalMarcRecord.FldFindNext(sTagToFind$) Then
-
- LocalMarcRecord.FldFindFirst sTagToFind$
- FindFieldCurrentlyPointedTo = LocalMarcRecord.FldPointer
- Exit Function
- End If
-
-
-
-
-
-
-
- sField$ = LocalMarcRecord.ReplaceCharacters(sField$, Chr(135), LocalMarcRecord.MarcDelimiter)
- LocalMarcRecord.FldMoveTop
- Do While LocalMarcRecord.FldFindNext(sTagToFind$)
- sLeft$ = LocalMarcRecord.FldTag + ":" + LocalMarcRecord.FldInd + ": " + LocalMarcRecord.AddSpacesAroundDelimiters(LocalMarcRecord.FldText)
-
- For lPtr = Len(sLeft$) To 1 Step -1
- Select Case Asc(Mid(sLeft$, lPtr, 1))
- Case Is > 191
- sLeft$ = LocalMarcRecord.SafeStuff(sLeft$, lPtr, 1, "?")
- Case Is > 127
- sLeft$ = LocalMarcRecord.SafeStuff(sLeft$, lPtr, 1, "")
- End Select
- Next
- If sField$ = sLeft$ Then
- FindFieldCurrentlyPointedTo = LocalMarcRecord.FldPointer
- Exit Function
- End If
- Loop
-
-
-
-
- End Function
- Public Function RomanizationAssistanceConvertWholeRecord(ByVal sRecordType$, ByVal iScript%, ByRef LocalMarcRecordObjectAlreadyLoadedWithRecord As Utf8MarcRecordClass, ByRef LocalMarcCharacterObject As Utf8CharClass) As Integer
- Dim sField$, sTag$, sTagToFind$, sIndicators$, s880Indicators$, sNative6$, s8806$, sLeftEnd$, sRecord$
- Dim sSelText$, sLeft$, sRight$, sRightAfterSelection$, sWholeField$, sWord$, sNewField$, sOldField$
- Dim sFieldRemainderRight$, sFieldRemainderLeft$, s6$, sOriginalField$, sSfd$, s066$
- Dim sTagToCopy$, sIndicatorsToCopy$, sFieldToCopy$, sNewFields$, sOldFields$
- Dim sSubfieldsExcludedUniversally$, sSubfieldsExcludedByTag$, sSubfield6Code$
- Dim sRLM$, sLRE$, sPDF$
-
- Dim iRc%, iRc2%, iRepeat%, iNext6%, iRomanizationStyle%, iDirection%
-
- Dim lPtr As Long, lSelLength As Long, lSelStart As Long, lStart As Long
- Dim lFldPointer As Long, lEnd As Long
-
- Dim bFound As Boolean, bSkipTagTest As Boolean
- Dim bCreateEmptyFields As Boolean, bCreateEmpty880s As Boolean
- Dim bLcPattern As Boolean
-
- Const sLineEnd = "\par"
- Const iLineEndLen = 5
-
- If gblaRomanizationTable(iScript%).DoNotUse880Field Then
- RomanizationAssistanceConvertWholeRecord = ROMANIZATIONRESULT_880NotAllowed%
- Exit Function
- End If
-
- If LocalMarcRecordObjectAlreadyLoadedWithRecord.FldFindFirst("880") Then
- RomanizationAssistanceConvertWholeRecord = ROMANIZATIONRESULT_880AlreadyPresent%
- Exit Function
- End If
-
-
-
-
-
-
- With LocalMarcRecordObjectAlreadyLoadedWithRecord
- iDirection% = ROMANIZATIONDIRECTION_Roman2Vernacular%
- .FldMoveTop
- Do While .FldMoveNext
-
-
- If InStr(gblaRomanizationTable(iScript%).V2RFieldsIncluded, .FldTag) > 0 Then
- Do
-
- If gblaRomanizationTable(iScript%).V2RCreateEmptyFields = True And _
- .Utf8TextContainsOnlyMarc8Characters(.SfdText) = False Then
- iDirection% = ROMANIZATIONDIRECTION_Vernacular2Roman%
- GoTo RomanAssist_HaveDirection
- ElseIf EvaluateFirstCharacter(.SfdText, iScript%, LocalMarcCharacterObject) = ROMANIZATIONDIRECTION_Vernacular2Roman% Then
- iDirection% = ROMANIZATIONDIRECTION_Vernacular2Roman%
- GoTo RomanAssist_HaveDirection
- End If
- If Not .SfdMoveNext Then
- Exit Do
- End If
- Loop
- End If
- Loop
- RomanAssist_HaveDirection:
- End With
-
-
-
- If iDirection% = ROMANIZATIONDIRECTION_Roman2Vernacular% Then
- If gblaRomanizationTable(iScript%).R2VCreateEmpty880s Then
- bCreateEmpty880s = True
-
-
-
-
- sSubfield6Code$ = gblaRomanizationTable(iScript%).R2VSubfield6Code
- If LenB(sSubfield6Code$) = 0 Then
- sSubfield6Code$ = Language2ScriptCode(LocalMarcRecordObjectAlreadyLoadedWithRecord.Get008Value(35, 3))
- End If
- If LenB(sSubfield6Code$) > 0 Then
- s066$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "c" + sSubfield6Code$
- If sSubfield6Code$ = CHARACTERSET_CODES_FOR_880_HebrewAsG0$ Or _
- sSubfield6Code$ = CHARACTERSET_CODES_FOR_880_BasicArabicAsG0$ Then
-
- sSubfield6Code$ = sSubfield6Code$ & "/r"
- End If
-
- sSubfield6Code$ = "/" + sSubfield6Code$
- End If
- End If
-
-
-
- If gblaRomanizationTable(iScript%).R2VIncludeFormattingCharactersLcPattern Or _
- InStr(sSubfield6Code$, "/r") > 0 Then
-
-
-
-
-
-
- bLcPattern = True
- With LocalMarcRecordObjectAlreadyLoadedWithRecord
- sRLM$ = .MarcRightToLeftMarker
- sLRE$ = .MarcLeftToRightEmbedding
- sPDF$ = .MarcPopDirectionalFormatting
- End With
- Else
-
-
-
-
-
-
- bLcPattern = False
- End If
- Else
- If gblaRomanizationTable(iScript%).V2RCreateEmptyFields = True Then
- bCreateEmptyFields = True
- End If
- End If
-
-
-
-
-
-
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveTop
- Do While LocalMarcRecordObjectAlreadyLoadedWithRecord.FldMoveNext
- DoEvents
- If Not LocalMarcRecordObjectAlreadyLoadedWithRecord.FldDeleted Then
- If iDirection% = ROMANIZATIONDIRECTION_Vernacular2Roman Then
- If InStr(gblaRomanizationTable(iScript%).V2RFieldsIncluded, LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag) = 0 Then
-
- GoTo RomanAssist_WholeRecordNextField
- End If
- sSubfieldsExcludedUniversally$ = gblaRomanizationTable(iScript%).V2RSubfieldsAlwaysExcluded
- sSubfieldsExcludedByTag$ = gblaRomanizationTable(iScript%).V2ROtherSubfieldsExcludedByTag
- Else
- If InStr(gblaRomanizationTable(iScript%).R2VFieldsIncluded, LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag) = 0 Then
- GoTo RomanAssist_WholeRecordNextField
- End If
- sSubfieldsExcludedUniversally$ = gblaRomanizationTable(iScript%).R2VSubfieldsAlwaysExcluded
- sSubfieldsExcludedByTag$ = gblaRomanizationTable(iScript%).R2VOtherSubfieldsExcludedByTag
- End If
- sTag$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag
- sNewField$ = ""
- sOldField$ = ""
- LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveFirst
- Do
-
-
-
-
-
- If bLcPattern Then
- sNewField$ = sNewField$ + sRLM$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode + sRLM$
- If sTag$ Like "26[04]" And LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode = "c" Then
- sNewField$ = sNewField$ + sLRE$
- End If
- Else
- sNewField$ = sNewField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode
- End If
- sOldField$ = sOldField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText
- If bCreateEmpty880s Or bCreateEmptyFields Then
- #If True Then
-
-
-
-
- If sTag$ Like "26[04]" And LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode = "c" And Right(LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, 1) = "." Then
- sNewField$ = sNewField$ + "+."
- Else
- sNewField$ = sNewField$ + "+"
- End If
- #Else
-
- sNewField$ = sNewField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText
- #End If
- ElseIf InStr(sSubfieldsExcludedUniversally$, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode) > 0 Then
-
- sNewField$ = sNewField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText
- ElseIf InStr(sSubfieldsExcludedByTag$, LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "/" + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode) > 0 Then
-
- sNewField$ = sNewField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText
- Else
- Select Case iDirection%
- Case ROMANIZATIONDIRECTION_Vernacular2Roman%, ROMANIZATIONDIRECTION_Roman2Vernacular%
- If LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode = "a" Then
- sSfd$ = ReRomanizeText(sRecordType$, sTag$, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject, iDirection%)
-
- sNewField$ = sNewField$ + ReRomanizeText(sRecordType$, sTag$, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject, iDirection%, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode)
- Else
- sNewField$ = sNewField$ + ReRomanizeText(sRecordType$, sTag$, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject, iDirection%, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode)
- End If
- Else
- sNewField$ = sNewField$ + ReRomanizeText(sRecordType$, sTag$, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText, iScript%, LocalMarcRecordObjectAlreadyLoadedWithRecord, LocalMarcCharacterObject, iDirection%, LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode)
- End If
- Case Else
- sNewField$ = sNewField$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdText
- End Select
- End If
-
-
-
- If bLcPattern Then
- If sTag$ Like "26[04]" And LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdCode = "c" Then
-
- If Right(sNewField$, 1) = "." Then
- sNewField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.SafeStuff(sNewField$, InStrRev(sNewField$, "."), 1, sPDF$ + ".")
- Else
- sNewField$ = sNewField$ + sPDF$
- End If
- End If
- End If
- If Not LocalMarcRecordObjectAlreadyLoadedWithRecord.SfdMoveNext Then
- Exit Do
- End If
- Loop
- sIndicators$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.FldInd
-
- If sTag$ >= 600 And sTag$ <= 651 Then
- s880Indicators$ = Mid$(sIndicators$, 1, 1) & "4"
- Else
- s880Indicators$ = sIndicators$
- End If
-
- If bCreateEmpty880s Then
-
- iNext6% = iNext6% + 1
- If Len(sNewFields$) > 0 Then
- sNewFields$ = sNewFields$ + vbLf
- sOldFields$ = sOldFields$ + vbLf
- End If
-
- #If True Then
-
-
- If bLcPattern Then
- sNewFields$ = sNewFields$ + "880" + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sSubfield6Code$ + sRLM$ + sNewField$
- Else
- sNewFields$ = sNewFields$ + "880" + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sSubfield6Code$ + sNewField$
- End If
- #Else
-
- If bLcPattern Then
- sNewFields$ = sNewFields$ + "880" + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sSubfield6Code$ + sRLM$ + sOldField$
- Else
- sNewFields$ = sNewFields$ + "880" + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sSubfield6Code$ + sOldField$
- End If
- #End If
- sOldFields$ = sOldFields$ + Trim(str(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer)) + vbTab + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + "880-" + Right("00" + Trim(str(iNext6%)), 2) + sOldField$
- ElseIf bCreateEmptyFields Then
-
- iNext6% = iNext6% + 1
- If Len(sNewFields$) > 0 Then
- sNewFields$ = sNewFields$ + vbLf
- sOldFields$ = sOldFields$ + vbLf
- End If
- #If True Then
-
-
- sNewFields$ = sNewFields$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + sIndicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6880-" + Right("00" + Trim(str(iNext6%)), 2) + sNewField$
- #Else
-
- sNewFields$ = sNewFields$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + sIndicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6880-" + Right("00" + Trim(str(iNext6%)), 2) + sOldField$
- #End If
- sOldFields$ = sOldFields$ + Trim(str(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer)) + vbTab + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sOldField$
- Else
- If sNewField$ <> sOldField$ Then
- iNext6% = iNext6% + 1
- If Len(sNewFields$) > 0 Then
- sNewFields$ = sNewFields$ + vbLf
- sOldFields$ = sOldFields$ + vbLf
- End If
- If iDirection% = ROMANIZATIONDIRECTION_Vernacular2Roman% Then
- sOldFields$ = sOldFields$ + Trim(str(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer)) + vbTab + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sOldField$
- sNewFields$ = sNewFields$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + sIndicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6880-" + Right("00" + Trim(str(iNext6%)), 2) + sNewField$
- Else
- sNewFields$ = sNewFields$ + "880" + s880Indicators$ + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + LocalMarcRecordObjectAlreadyLoadedWithRecord.FldTag + "-" + Right("00" + Trim(str(iNext6%)), 2) + sNewField$
- sOldFields$ = sOldFields$ + Trim(str(LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer)) + vbTab + LocalMarcRecordObjectAlreadyLoadedWithRecord.MarcDelimiter + "6" + "880-" + Right("00" + Trim(str(iNext6%)), 2) + sOldField$
- End If
- End If
- End If
- End If
- RomanAssist_WholeRecordNextField:
- Loop
- Do While Len(sOldFields$) > 0
- DoEvents
- GetNextPiece sOldFields$, sField$, vbLf
- If iDirection% = ROMANIZATIONDIRECTION_Vernacular2Roman% Then
- GetNextPiece sField$, sTag$, vbTab
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = Val(sTag$)
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldDelete
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldAdd "880", Mid(sField$, 1, 2), Mid(sField$, 3)
- Else
- GetNextPiece sField$, sTag$, vbTab
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldPointer = Val(sTag$)
-
- If LenB(gblaRomanizationTable(iScript%).R2VVowelMarker) > 0 Then
- sField$ = LocalMarcRecordObjectAlreadyLoadedWithRecord.ReplaceCharacters(sField$, gblaRomanizationTable(iScript%).R2VVowelMarker)
- End If
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldText = sField$
- End If
- Loop
- Do While Len(sNewFields$) > 0
- GetNextPiece sNewFields$, sField$, vbLf
- If iDirection% = ROMANIZATIONDIRECTION_Vernacular2Roman% Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldAdd Mid(sField$, 1, 3), Mid(sField$, 4, 2), LocalMarcRecordObjectAlreadyLoadedWithRecord.UCaseFirstWord(Mid(sField$, 6))
- Else
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldAdd Mid(sField$, 1, 3), Mid(sField$, 4, 2), Mid(sField$, 6)
- End If
- Loop
-
-
-
- If bCreateEmpty880s And LenB(s066$) > 0 Then
- If Not LocalMarcRecordObjectAlreadyLoadedWithRecord.FldFindFirst("066") Then
- LocalMarcRecordObjectAlreadyLoadedWithRecord.FldAdd "066", " ", s066$
- End If
- End If
-
-
- End Function
- Public Sub ReRomanizeAdjustNonfilingIndicators(iScript%, ByVal sNonfilingTagString$, ByVal lPointerToOriginalField As Long, ByVal lPointerToNewField As Long, ByRef LocalMarcRecord As Utf8MarcRecordClass, ByRef LocalCharacterObject As Utf8CharClass)
- Dim iNonfiling%, iNonfilingIndicator%, iRc%, iLen%
-
- Dim sOriginal$
-
-
- With LocalMarcRecord
- .FldPointer = lPointerToOriginalField
- If .SfdFindFirst("a") Then
- If .FldTag = "880" Then
- If .SfdFindFirst("6") Then
- iRc% = InStr(sNonfilingTagString$, Mid(.SfdText, 1, 3))
- End If
- .SfdFindFirst "a"
- Else
- iRc% = InStr(sNonfilingTagString$, .FldTag)
- End If
- If iRc% > 0 Then
- iNonfiling% = Val(Mid(sNonfilingTagString$, iRc% + 4, 1))
- If iNonfiling% > 0 Then
-
-
-
- iNonfilingIndicator% = Val(Mid(.FldInd, iNonfiling%, 1))
- If iNonfilingIndicator% > 0 Then
- sOriginal$ = .SafeMid(.SfdText, 1, iNonfilingIndicator%)
- .FldPointer = lPointerToNewField
- If .SfdFindFirst("a") Then
- If Mid(.SfdText, 1, Len(sOriginal$)) <> sOriginal$ Then
-
-
-
-
-
-
-
- If .FldTag = "880" Then
-
-
-
- sOriginal$ = ReRomanizeText("B", "500", sOriginal$, iScript%, LocalMarcRecord, LocalCharacterObject, ROMANIZATIONDIRECTION_Roman2Vernacular%)
- Else
-
-
-
- sOriginal$ = ReRomanizeText("B", "500", sOriginal$, iScript%, LocalMarcRecord, LocalCharacterObject, ROMANIZATIONDIRECTION_Vernacular2Roman%)
- End If
- If Mid(.SfdText, 1, Len(sOriginal$)) = sOriginal$ Then
- iLen% = .SafeLen(sOriginal$)
- If iLen% < 9 Then
-
- If .SfdFindFirst("6") = True Then
- If Mid$(.SfdText, 5, 2) <> "00" Then
- gbliReSequenceTableLast% = gbliReSequenceTableLast% + 1
- ReDim Preserve gblaReSequenceTable(gbliReSequenceTableLast%)
- gblaReSequenceTable(gbliReSequenceTableLast%).Tag = .FldTag
- gblaReSequenceTable(gbliReSequenceTableLast%).Field = .FldText
- gblaReSequenceTable(gbliReSequenceTableLast%).Sequence = gbliReSequenceTableLast%
-
-
- End If
- End If
- End If
- Loop
-
- If gbliReSequenceTableLast% = 0 Then Exit Function
-
-
- .FldMoveTop
- Do While .FldMoveNext
-
- If .FldTag = "880" Then
- If .SfdFindFirst("6") = True Then
-
- If Mid$(.SfdText, 1, 3) >= 600 And Mid$(.SfdText, 1, 3) <= 651 Then
- .FldInd2 = "4"
- End If
- If Mid$(.SfdText, 5, 2) <> "00" Then
- bMatchFound = False
- For iCtr% = 1 To gbliReSequenceTableLast%
-
- If gblaReSequenceTable(iCtr%).Sequence880 = 0 Then
-
-
- If Mid$(.SfdText, 1, 3) = gblaReSequenceTable(iCtr%).Tag Then
- gblaReSequenceTable(iCtr%).LinkTag = gblaReSequenceTable(iCtr%).Tag
- gblaReSequenceTable(iCtr%).Field880 = .FldText
- gblaReSequenceTable(iCtr%).Sequence880 = gblaReSequenceTable(iCtr%).Sequence
- bMatchFound = True
- Exit For
- End If
- End If
- Next
- End If
-
- If bMatchFound = False Or Mid$(.SfdText, 5, 2) = "00" Then
- gbliReSequenceTableLast% = gbliReSequenceTableLast% + 1
- ReDim Preserve gblaReSequenceTable(gbliReSequenceTableLast%)
- gblaReSequenceTable(gbliReSequenceTableLast%).Tag = .FldTag
- gblaReSequenceTable(gbliReSequenceTableLast%).Field = .FldText
- gblaReSequenceTable(gbliReSequenceTableLast%).Sequence = 0
- gblaReSequenceTable(gbliReSequenceTableLast%).Sequence880 = 0
- End If
- End If
- End If
- Loop
-
-
- .FldMoveTop
- Do While .FldMoveNext
-
- lPtr& = .FldPointer
- If Val(.FldTag) > 99 Then
- If .SfdFindFirst("6") = True Then
-
- For iCtr% = 1 To gbliReSequenceTableLast%
-
-
-
-
- If .FldTag = gblaReSequenceTable(iCtr%).Tag And _
- .FldText = gblaReSequenceTable(iCtr%).Field Then
- .SfdText = .SafeStuff(.SfdText, 5, 2, Right("00" & CStr(gblaReSequenceTable(iCtr%).Sequence), 2))
-
- gblaReSequenceTable(iCtr%).Field = ""
- Exit For
-
- ElseIf Mid$(.SfdText, 1, 3) = gblaReSequenceTable(iCtr%).LinkTag And _
- .FldText = gblaReSequenceTable(iCtr%).Field880 Then
- .SfdText = .SafeStuff(.SfdText, 5, 2, Right("00" & CStr(gblaReSequenceTable(iCtr%).Sequence880), 2))
-
- gblaReSequenceTable(iCtr%).Field880 = ""
- Exit For
- End If
- Next
- End If
- End If
-
- .FldPointer = lPtr&
- Loop
-
- End With
-
-
- Erase gblaReSequenceTable
- End Function
- Public Function AddCharSetCodes2Utf8Record(ByRef LocalMarcRecordObjectAlreadyLoadedWithRecord As Utf8MarcRecordClass, ByVal iScript%)
- Dim iPtr%, iCtr%, iNonfiling%, iIndicator%
- Dim bChanged As Boolean, bError As Boolean
- Dim sTag$, sIndicators$, sField$, sNonfiling$, sChar$
- Dim sCharacterSetsPresent$, s066$, sSfd6$, sPiece$
- Dim bLcPattern As Boolean
-
- If gblaRomanizationTable(iScript%).R2VIncludeFormattingCharactersLcPattern Then bLcPattern = True
-
- With LocalMarcRecordObjectAlreadyLoadedWithRecord
- .FldMoveTop
- Do While .FldMoveNext
- iPtr% = .FldPointer
-
- If .FldTag = "066" And gblaRomanizationTable(iScript%).R2VCreateEmpty880s = False Then .FldDelete
-
- If .FldTag = "880" Then
- .FldLoadInfo sTag$, sIndicators$, sField$
- .TranslateUtf82MarcOneField sCharacterSetsPresent$, sTag$, sField$, bChanged, bError
- If bChanged Then
- If .SfdFindFirst("6") = True And _
- .ExtractSubfield(sField$, "6", sSfd6$) > 0 Then
-
- If bLcPattern Or InStr(sSfd6$, "/r") > 0 Then
- sSfd6$ = sSfd6$ & .MarcRightToLeftMarker
- End If
- .SfdChange "6", sSfd6$
- End If
- End If
-
-
- If bLcPattern Or InStr(sSfd6$, "/r") > 0 Then
- .FldText = .TranslateMarc2Utf8OneFieldLcPattern("880", .FldText)
-
- .FldText = .RemoveRepeatedCharacters(.FldText, .MarcRightToLeftMarker)
- .FldText = .RemoveRepeatedCharacters(.FldText, .MarcLeftToRightEmbedding)
- .FldText = .RemoveRepeatedCharacters(.FldText, .MarcPopDirectionalFormatting)
- End If
- End If
- .FldPointer = iPtr%
- Loop
-
-
-
- sCharacterSetsPresent$ = .RemoveRepeatedCharacters(Trim(sCharacterSetsPresent$), " ")
- s066$ = .TranslateUtf82MarcCharacterSetString(sCharacterSetsPresent$, .MarcDelimiter + "c")
- If Len(s066$) > 0 Then
- If Not .FldFindFirst("066") Or gblaRomanizationTable(iScript%).R2VCreateEmpty880s = False Then
- .FldAddGeneric "066", " ", s066$, 3
- ElseIf .FldText <> s066$ Then
- .FldChange "066", " ", s066$
- End If
- End If
-
- End With
-
- End Function
- Public Function RomanizeConvertDecimalChars(ByVal sIn$, ByRef LocalMarcRecordObject As Utf8MarcRecordClass, ByRef LocalCharacterObject As Utf8CharClass) As String
-
- Dim lPtr As Long
-
- Dim sLeader$, sOriginal$, sHexChar$
- Dim iDigits%
-
- Dim bShow As Boolean
-
-
-
-
-
-
- sLeader$ = "&#"
-
- Do
- lPtr = InStr(sIn$, sLeader$)
- Do While lPtr > 0
-
- iDigits% = Len(CStr(Val(Mid$(sIn$, lPtr + 2, 5))))
- sHexChar$ = Hex$(Mid$(sIn$, lPtr + 2, iDigits%))
- LocalCharacterObject.UcsHex = Right$(String$(4 - Len(sHexChar$), "0") & sHexChar$, 4)
- sIn$ = LocalMarcRecordObject.SafeStuff(sIn$, lPtr, iDigits% + 2, LocalCharacterObject.Utf8Char)
- lPtr = InStr(sIn$, sLeader$)
- Loop
- Select Case sLeader$
- Case "&#"
-
- sLeader$ = "\\\"
-
- Case "\\\"
- Exit Do
- End Select
- Loop
-
- RomanizeConvertDecimalChars = sIn$
-
- End Function
- Public Function FindScriptByKeyPress(ByRef c As Control, ByRef KeyAscii As Integer)
-
- Dim cb As Long
- Dim FindString As String
-
- If KeyAscii < 32 Or KeyAscii > 127 Then Exit Function
-
- If c.SelLength = 0 Then
- FindString = c.Text & Chr$(KeyAscii)
- Else
- FindString = Left$(c.Text, c.SelStart) & Chr$(KeyAscii)
- End If
-
- cb = SendMessage(c.hWnd, CB_FINDSTRING, -1, ByVal FindString)
-
- If cb <> CB_ERR Then
- c.ListIndex = cb
- c.SelStart = Len(FindString)
- c.SelLength = Len(c.Text) - c.SelStart
- End If
-
- KeyAscii = 0
-
- End Function
- Public Function IsFontInstalled(FontName As String) As Boolean
-
-
-
- Dim oFont As New StdFont
-
- On Error Resume Next
-
- IsFontInstalled = False
-
- If LenB(FontName) > 0 Then
- With oFont
- .Name = FontName
- If StrComp(FontName, .Name, vbTextCompare) = 0 Then IsFontInstalled = True
- End With
- End If
- Set oFont = Nothing
-
- End Function
- Public Function CreateRomanizationScriptList(ByRef sConfigurationFilePath$, ByRef sScripts2Load As String)
- Dim sMasterFile$, sFile$
- Dim sScripts2LoadList$()
- Dim iCtr%, iPtr%
- Dim bLoadAllScripts As Boolean
- sMasterFile$ = sConfigurationFilePath$ + "RomanizationMaster.cfg"
- If sScripts2Load$ = vbNullString Then
- bLoadAllScripts = True
- Else
- sScripts2LoadList$() = Split(sScripts2Load$)
- End If
-
- gbliRomanizationScriptLast% = 0
- gbliRomanizationTablesBytes# = 0
- Do
- iCtr% = gbliRomanizationScriptLast% + 1
- sFile$ = ReadIniFileOrNothing(sMasterFile$, "Files", Trim(str(iCtr%)), 250)
-
- If LenB(sFile$) = 0 Then Exit Do
-
- gbliRomanizationScriptLast% = gbliRomanizationScriptLast% + 1
- ReDim Preserve gblaRomanizationScript(gbliRomanizationScriptLast%)
-
- If InStr(sFile$, "\") = 0 Then
- If LenB(Dir$(sConfigurationFilePath$ + sFile$)) Then
- gblaRomanizationScript(gbliRomanizationScriptLast%).Name = ReadIniFileOrNothing(sConfigurationFilePath$ + sFile$, "General", "Name", 100)
- gblaRomanizationScript(gbliRomanizationScriptLast%).FileSize = FileLen(sConfigurationFilePath$ + sFile$)
- End If
- Else
- If LenB(Dir$(sFile$)) Then
- gblaRomanizationScript(gbliRomanizationScriptLast%).Name = ReadIniFileOrNothing(sFile$, "General", "Name", 100)
- gblaRomanizationScript(gbliRomanizationScriptLast%).FileSize = FileLen(sFile$)
- End If
- End If
- If bLoadAllScripts Then
- gblaRomanizationScript(gbliRomanizationScriptLast%).LoadScript = True
- gbliRomanizationTablesBytes# = gbliRomanizationTablesBytes# + gblaRomanizationScript(gbliRomanizationScriptLast%).FileSize
- Else
- gblaRomanizationScript(gbliRomanizationScriptLast%).LoadScript = False
- For iPtr% = 0 To UBound(sScripts2LoadList$)
- If CInt(sScripts2LoadList$(iPtr%)) = gbliRomanizationScriptLast% Then
- gblaRomanizationScript(gbliRomanizationScriptLast%).LoadScript = True
- gbliRomanizationTablesBytes# = gbliRomanizationTablesBytes# + gblaRomanizationScript(gbliRomanizationScriptLast%).FileSize
- End If
- Next
- End If
- Loop
-
- End Function
- Public Sub LoadRomanizationTablesProgress(l As Long, ProgressBarCtrl As Control)
- If ProgressBarCtrl.Value < (ProgressBarCtrl.Max - l) Then
- ProgressBarCtrl.Value = ProgressBarCtrl.Value + l
- End If
-
- End Sub
|