Baby’s First Macro

Who doesn’t wish OCLC would work a little differently than it does? A little extra feature here, a little extra feature there…if you’ve worked with it for any amount of time, you’ve probably gotten a little frustrated at times.

This was what I wanted on March 10th — so I decided to knuckle down, look up how to make an OCLC macro, and I done did it! I’m sure it could be done better, that it could be done faster or more efficiently, but it totally works — and for me, that’s enough for now.

I first grabbed the contents of the Cont fixed field and Indx fixed field and stored them in string variables.

The macro then checks three cases:

  1. If the Cont field contains a ‘b’ and Indx is ‘1’ then it adds a 504 field with the value “Includes bibliographical references and index”
  2. If the Cont field contains a ‘b’ and Indx is ‘0’ or uncoded then it adds a 504 field with the value “Includes bibliographical references”
  3. If the Cont field does not contain a ‘b’ and Indx is 1, then it adds a 500 field with the value “Includes index.

So here it is copied below, feel free to use it, re-use it, or improve it (but if you do, lemme know!).

Sub Main
    Dim CS As Object
Set CS = CreateObject("Connex.Client")
CS.GetFixedField "Cont", ContCode$
CS.GetFixedField "Indx", IndxCode$

If InStr(ContCode$, "b") and IndxCode$ = "1" Then
CS.AddField 1, "504  Includes bibliographical references and index."
End If

If InStr(ContCode$, "b") and (IndxCode$ = "" or IndxCode$ = "0") Then
CS.AddField 1, "504  Includes bibliographical references."
End If

If InStr(ContCode$, "b")=0 and IndxCode$ = "1" Then
CS.AddField 1, "500  Includes index."
End If
End Sub
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s