Writing OCLC Connexion Client Macros
the simple way!
Simplicity is the key to success when writing macros for OCLC Connexion Client, just as it is when writing macros for any other software application.
In most cases, short, simple macros can instruct the OCLC Connexion Client software to perform the same complex operations that long, intricately-structured macros do. The secret to writing simple macros is simply to write macros that tell OCLC Connexion Client to do only what you want it to do and nothing more.
Look at the two macro samples below:
Sub Main
        dim CS As Object
        set CS = CreateObject("Connex.Client")
        If CS.IsOnline = False Then
        CS.Logon "", "", ""
        End If
        If CS.Logon("","","") = True Then
        MsgBox "Logon successful"
        End if
End Sub
Sub Main
        dim CS as object
        set CS = CreateObject("Connex.Client")
        CS.Logon "", "", ""
End Sub
Both macros log on to OCLC Connexion Client. But one macro is ten lines long, and the other is five lines long.
The ten-line macro appears as an example in the OCLC Connexion Client Help files.
The five-line macro is the result of my sweeping through the Help file example the same way I sweep through my desk drawers, throwing out everything I don't need.
Those extra lines in the ten-line example do two (unnecessary) things which my five-line macro does not. One is to check to see if the user is logged on, and, if not, to log on. The other is to pop up a message box which tells you the logon succeeded.
My macro does not waste computer time and memory to determine whether or not you are logged on. Your computer has sense enough to log on if you are not already logged on, and to skip logging on if you are already logged on. If you run my macro while you are already logged on, guess what happens. That's right! Nothing.
My macro also does not include a message box to tell you that the logon was successful. This saves macro-writing time and saves you the time it takes to close the message box after the macro runs.
Here are two more macros that tell your computer to do the same thing (divide a lengthy 505 fieldline into two separate fieldlines). One of my coworkers wrote the first version, and I wrote the second.
'Macro © Martin Selditch
Sub Main
        dim CS as object
        set CS = CreateObject("Connex.Client")
        Dim x1 as Integer
        Dim y1 as Integer
        Dim x2 as Integer
        Dim y2 as Integer
        y1 = CS.CursorPosition - 2
        x1 = CS.CursorRow
        CS.EndCell
        y2 = CS.CursorPosition
        x2 = CS.CursorRow
        CS.Cut x1,y1,x2,y2
        CS.AddField 2, "50580"
        CS.CursorPosition = 12
        CS.Paste
End Sub
'Macro © Merry Morris
Sub Main
        dim CS as object
        set CS = CreateObject("Connex.Client")
        CS.CutSelected
        CS.AddField 2, "50580"
        CS.CursorPosition=12
        CS.Paste
End Sub
To see how these macros change a 505 field, click here
As you can see, the eight-line macro has fewer lines than the seventeen-line macro.
Both macros allow you to place the cursor at the precise point where you want to divide the lengthy 505 field into two separate 505 fields. The only difference between the two for the user is that the shorter macro requires the user to hold down the left mouse button and highlight all text to the end of the 505 field before running the macro. Given the less-than-a-split second time it takes to do that, it hardly seems worth writing all those extra lines of code to avoid it.
The eight-line macro also has easier to understand command lines. (Not just for you, but for the computer, too.) And some of those lines in the seventeen-line macro appear to have something which frightens many people: the hint of algebra. (My coworker has a degree in mathematics, so he didn't frighten himself when he wrote his version of this macro.)
I got "A's" in algebra in high school and in college, but I still prefer to avoid using it in real life, particularly when writing computer commands because I know that accidentally telling the computer to do something with "x" when you meant to type "y" can cause the computer to whirr and clunk until you recover your senses, shut the computer down, and perform a "cold reboot".
So far, at least, the most I have had to do when I made a typographical error in writing my simple macros was to close the message box which informed me that my macro "failed to complete", then find and correct the typographical error.
If you write simple macros like my seven-line macro, you will save:
(1) macro typing time
(2) macro error-checking time
(3) brain cells necessary to understand and remember the macro code
(4) a few bytes of computer space
(5) a couple of nanoseconds of macro runtime
(6) and, most significant of all, you will save yourself unnecessary clicking and/or keystrokes before, during, and after your macros run.
If you like my approach to writing macros, click here to see my mini-tutorial on writing simple OCLC Connexion Client macros.
|