' MacroName: Headers ' MacroDescription: Get the info for CLSI's 001, 003, and 008 ' fields from OCLC and insert it into CLSI ' Written by: Joel Hahn, Niles Public Library District Declare function CheckMessage(Text$, Beginning$, Ending$) Declare function CheckLine(Tag$) '*************************************************** function CheckMessage(Text$, Beginning$, Ending$) bRetVal = FALSE Temp$ = Left$(Text$, Len(Beginning$)) if StrComp(Beginning$, Temp$) = 0 then Temp$ = Right$(Text$, Len(Ending$)) if StrComp(Ending$, Temp$) = 0 then bRetVal = TRUE end if end if CheckMessage = bRetVal end function '*************************************************** function CheckLine(Tag$) tRetVal=FALSE Dim CCSTest as Session Set CCSTest = CurrentSession Crow%=(CCSTest.CursorRow) CCSTest.GetTextInRegion CheckTag$, Crow%, 17, Crow%, 19 'MsgBox CheckTag$ & "|" & Tag$ If CheckTag$=Tag$ Then tRetVal=TRUE CheckLine=tRetVal end function '*************************************************** sub main Dim CS as Session Set CS = CurrentSession Dim CCS as Session Dim CCSSession as Session 'Set up Session names 'CurSession [also CS] is OCLC; find the next open non-OCLC 'session and make it CCSSession. Commands may then be sent 'to either session by choosing the proper preface. CurrentSession.GetName CurSession$ NumSessions%=GetNumSessions() For i=1 to NumSessions% Set CCS=GetSession(i) CCS.GetName SessionName$ If (SessionName$<>CurSession$) Then Set CCSSession=CCS End if Next i CCSSession.GetTextInRegion MarcTest$, 3, 32, 3, 37 If Left(Trim(MarcTest$), 4)<>"MARC" Then MsgBox "CLSI display is not in a MARC record. Aborting..." Goto Done End If 'If the cursor is not currently in the Tag column of the 'MARC display, move it there cc=CCSSession.CursorColumn If cc=21 or cc=22 Then CCSSession.Send "\x09\x09\x09" CCSSession.Receive 5, "[?25l" ElseIf cc=25 Then CCSSession.Send "\x09\x09" CCSSession.Receive 5, "[?25l" ElseIf cc>=27 Then CCSSession.Send "\x09" CCSSession.Receive 5, "[?25l" End If 'Make sure cursor is at the first available line of the MARC 'display, moving it there if necessary ccr=CCSSession.CursorRow CCSSession.GetTextInRegion LinNums$, 3, 1, 3, 80 LNplace=Instr(LinNums$, "Line") LinNums$=Right(LinNums$, Len(LinNums$)-LNplace) LNplace2=Instr(LinNums$, "of") CurLin=Val(Mid(LinNums$, 4, LNplace2-4)) If CurLin<>3 Then UpLine=CurLin Do CCSSession.Send "\x1B[A" CCSSession.Receive 5, "[?25l" UpLine=UpLine-1 Loop while UpLine>3 CCSSession.Send "\x1B[17~" '[F6] End If ' Determine how many columns are in the record if CS.CommMode = BLOCK then Columns% = CS.BlockColumns else Columns% = CS.FDXColumns end if ' Make sure we are at the top of the record CS.GetTextInRegion Text$, 2, 1, 2, Columns% ' Check for "Entire --- displayed." if CheckMessage(Text$, "Entire ", " displayed.") = FALSE then ' Check for "Beginning of --- displayed." if CheckMessage(Text$, "Beginning of ", " displayed.") = FALSE then ' Check for "You are already at beginning of the ---" if CheckMessage(Text$, "You are already at beginning of the ", "") = FALSE then ' Check for "You are already viewing the entire ---" if CheckMessage(Text$, "You are already viewing the entire ", "") = FALSE then ' Move position to the beginning of the record CS.PutText "HOME", 1, 1 RunMacro "PRSMUTIL!SendCommand" end if end if end if end if ' Get text to be printed Row% = CS.GetLastRowUsed CS.GetTextInRegion Temp$, 6, 1, Row%, Columns%, TRUE Buffer$ = Buffer$ + Temp$ wraps=0 For g=1 to LEN(Buffer$) If mid(Buffer$, g, 1)=CHR$(13) then wraps=wraps+1 Next g crlf=CHR$(13)+CHR$(10) for g=1 to wraps place=InStr(Buffer$, crlf) l$=Left(Buffer$, place-1) r$=Right(Buffer$, (Len(Buffer$)-(place+1))) '*** Buffer$=l$+r$ next g Set CurrentSession = CCSSession '*************************************************** FixedFields: '001, 003, 008 dim a$ dim b$ dim o$ dim z$ EOL=CHR$(221) b$=GetField(Buffer$, 1, EOL) 'b$=" OCLC: 34939432 Rec stat: c"+"\r" 'b$=b$+" Entered: 19960617 Replaced: 19960617" 'b$=b$+" Used: 19961009"+"\r" 'b$=b$+CHR$(220)+" Type: a ELvl: I Srce: d Audn:" 'b$=b$+" Ctrl: Lang: eng"+"\r" 'b$=b$+" BLvl: m Form: Conf: 0 Biog:" 'b$=b$+" MRec: Ctry: nyu"+"\r" 'b$=b$+" Cont: b GPub: Fict:" 'b$=b$+" 0 Indx: 1"+"\r" 'b$=b$+" Desc: a Ills: a Fest: 0 DtSt:" 'b$=b$+" s Dates: 1996, "+CHR$(221) 'Get Leader info place=InStr(b$, "Rec stat") lead$=Mid(b$, place+13, 1) place=InStr(b$, "Type") lead$=lead$+Mid(b$, place+7, 1) place=InStr(b$, "BLvl") lead$=lead$+Mid(b$, place+7, 1) place=InStr(b$, "ELvl") lead$=lead$+Mid(b$, place+7, 1) place=InStr(b$, "Desc") lead$=lead$+Mid(b$, place+7, 1) 'Send a Sh-F7, then send the leader info, then send Sh-F10 CCSSession.Send "\x1B[32~" CCSSession.Send lead$ CCSSession.Send "\x1B[21~" OneX=0 '0=doesn't need to be added; 1=needs to be added ThreeX=0 '0=doesn't need to be added; 1=needs to be added CCSSession.GetTextInRegion InsOvr$, 21, 70, 21, 75 If InsOvr$="OVERST" Then CCSSession.Send "\x1B[K" CCSSession.Receive 3, "INSERT" End If CCSSession.GetTextInRegion One$, 7, 17, 7, 19 CCSSession.GetTextInRegion Three$, 8, 17, 8, 19 If One$<>"001" Then OneX=1 If (One$<>"003") and (Three$<>"003") Then ThreeX=1 a$="001ocm" place=0 place=InStr(b$, "OCLC") o$=RTrim(Mid(b$, place+7, 8)) If 8-Len(o$)<>0 Then For i=1 to (8-Len(o$)) o$="0"+o$ Next i End if a$=a$+o$ If OneX=0 Then CCSSession.Send "\x1B[2~" End If If ThreeX=0 Then CCSSession.Send "\x1B[2~" End If CCSSession.Send "\x1B[B" CCSSession.Send "1\x1B[2~" CCSSession.Send "\x1B[A" CCSSession.Send "\r" CCSSession.Send a$ CCSSession.Send "\r" CCSSession.Send "003OCoLC" CCSSession.Send "\r" 'Start Header info; get info for first 18 positions a$="008" place=InStr(b$, "Entered") a$=a$+Mid(b$, place+14, 6) place=InStr(b$, "DtSt") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Dates") a$=a$+Mid(b$, place+7, 4)+Mid(b$, place+12, 4) place=InStr(b$, "Ctry") a$=a$+Mid(b$, place+7, 3) 'Get Type, goto Fixed Fields set for the appropriate format place=InStr(b$, "Type") typ=ASC(Mid(b$, place+7, 1)) TwoFifty: Select Case typ Case 97 'Type="a" If InStr(b$, "SrTp")=0 then Goto Bks Else Goto Ser Case 99 'Type="c" Goto Sco Case 101 'Type="e" Goto Map Case 103, 107, 111 'Type="g", "k", or "o" Goto Vis Case 105, 106 'Type="i" or "j" Goto Rec Case 109 'Type="m" Goto Com End Select Bks: place=InStr(b$, "Ills") a$=a$+Mid(b$, place+7, 4) place=InStr(b$, "Audn") 'aka Int Lvl a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Form") 'aka Repr a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Cont") a$=a$+Mid(b$, place+7, 4) place=InStr(b$, "GPub") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Conf") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Fest") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Indx") a$=a$+Mid(b$, place+7, 1) a$=a$+" " 'aka MEBE place=InStr(b$, "LitF") 'aka Fict a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Biog") a$=a$+Mid(b$, place+7, 1) Goto End008 Ser: place=InStr(b$, "Freq") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Regl") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "ISSN") 'aka ISDS a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "SrTp") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Orig") 'aka Phys.Med. ThreeH: a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Form") 'aka Repr a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "EntW") 'aka 1st character of Cont a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Cont") 'aka 2nd-4th char's of Cont a$=a$+Mid(b$, place+7, 3) place=InStr(b$, "GPub") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Conf") a$=a$+Mid(b$, place+7, 1) a$=a$+" " 'aka Titl page a$=a$+" " 'aka Index a$=a$+" " 'aka Cum Index place=InStr(b$, "Alph") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "S/L") a$=a$+Mid(b$, place+7, 1) Goto End008 Sco: place=InStr(b$, "Comp") a$=a$+Mid(b$, place+7, 2) place=InStr(b$, "FMus") 'aka Format a$=a$+Mid(b$, place+7, 1) a$=a$+" " 'aka Prts place=InStr(b$, "Audn") 'aka Int lvl a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Form") 'aka Repr a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "AccM") a$=a$+Mid(b$, place+7, 6) place=InStr(b$, "LTxt") a$=a$+Mid(b$, place+7, 2) a$=a$+" " 'aka MEBE a$=a$+" " 'aka ??? a$=a$+" " Goto End008 Com: a$=a$+" " 'aka ??? a$=a$+" " '(3) place=InStr(b$, "Audn") a$=a$+Mid(b$, place+7, 1) a$=a$+" " 'Form, aka Repr [not used for COM in OCLC] a$=a$+" " '(2) place=InStr(b$, "File") a$=a$+Mid(b$, place+7, 1) a$=a$+" " a$=a$+" " 'aka GPub? ThreeFifty: a$=a$+" " '(6) Goto End008 Vis: place=InStr(b$, "Time") 'aka Leng a$=a$+Mid(b$, place+7, 3) a$=a$+" " 'aka InLC place=InStr(b$, "Audn") 'aka Int Lvl a$=a$+Mid(b$, place+7, 1) a$=a$+" " 'Mid(b$, place+7, 5) 'aka AccM place=InStr(b$, "GPub") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Form") a$=a$+Mid(b$, place+7, 1) a$=a$+" " '(2) [previously 3] a$=a$+" " 'aka MEBE place=InStr(b$, "TMat") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Tech") a$=a$+Mid(b$, place+7, 1) Goto End008 Rec: place=InStr(b$, "Comp") a$=a$+Mid(b$, place+7, 2) place=InStr(b$, "FMus") a$=a$+Mid(b$, place+7, 1) a$=a$+" " 'aka Prts place=InStr(b$, "Audn") 'aka Int Lvl a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Form") 'aka Repr a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "AccM") a$=a$+Mid(b$, place+7, 6) place=InStr(b$, "LTxt") a$=a$+Mid(b$, place+7, 2) a$=a$+" " 'aka MEBE a$=a$+" " '(2) Goto End008 Map: place=InStr(b$, "Relf") a$=a$+Mid(b$, place+7, 4) a$=a$+" " 'Mid(b$, place+7, 1) 'aka 1st character of Base; aka Prme place=InStr(b$, "Proj") 'aka 2nd-3rd char's of Base a$=a$+Mid(b$, place+7, 2) place=InStr(b$, "CrTp") 'aka RecG a$=a$+Mid(b$, place+7, 1) a$=a$+" " '(2) place=InStr(b$, "GPub") FourH: a$=a$+Mid(b$, place+7, 1) a$=a$+" " '(2) a$=a$+" " 'aka Indx? a$=a$+" " place=InStr(b$, "SpFm") 'aka Form a$=a$+Mid(b$, place+7, 2) Goto End008 End008: place=InStr(b$, "Lang") a$=a$+Mid(b$, place+7, 3) place=InStr(b$, "MRec") a$=a$+Mid(b$, place+7, 1) place=InStr(b$, "Srce") a$=a$+Mid(b$, place+7, 1) 'a$=a$+"\x09" DoIt: CCSSession.Send a$ CCSSession.Send "\x09" Done: end sub