Macros
These instructions will provide the basics for writing an OCLC Macro Language (OML) macro that inserts a simple field into a bibliographic record in the Connexion Client. This document only shows fields without subfields. If you need to have subfields, please read this document first, then read OML Macros and Subfield Delimiters.
Example: We need a macro to insert a simple 500 index note.
Step 1: From the menu choose Tools—›Macros—›Manage… The following dialog box will appear:

When looking at the above figure, please notice the structure of the macros list display. It's very similar to the file directory display used in Windows Explorer. You can click on the "plus sign" to open up each entry to reveal sub-entries. Each entry in the list represents a macrobook. Each sub-entry is a macro within the macrobook. As you can see, you can have any number of macrobooks, with one or more macros in each one.
Step 2: Let's make our very own macrobook to store our personal macros in. Click on the New Book button. The dialog box should now look like this:

Pressing on the New Book button creates a new entry in the list of macrobooks. A default name of "NewBook" is made, but is highlighted so that you can rename it.
Step 3: While "NewBook" is highlighted, type in the new name for your macrobook. You can call it anything you want to, but make sure it contains no spaces because Connexion doesn't like that and will give you an error message. In the example below, we called our new macrobook "MyMacros."

Note: If for some reason the entry doesn't look editable (perhaps you moved to another window before renaming it), you can make it editable again by clicking on the entry once to highlight it, then clicking on it just once more. It should now be editable.
Step 4: Make sure your new macrobook is highlighted. If it isn't, just click on it once. Now click on the New Macro button. A dialog box will appear asking for a macro description. For this example, we typed in "Index note." When finished, click on the OK button.

Step 5: Your new macro will now display as a sub-entry within your new macrobook as shown in the figure below. It will be given the default name "NewMacro." The description you provided in the previous step will display in the box below the list.

Step 6: While your new macro is highlighted and editable, type in a new name for it. Like before, make sure there are no spaces in the name. For this example, we decided to call it "IndexNote" as shown below.

Note: If for some reason the macro name doesn't look editable (perhaps you moved to another window before renaming it), you can make it editable again by clicking on the entry once to highlight it, then clicking on it just once more. It should now be editable.
Step 7: Now that we have a new macro, we'll need to make it do something useful. All new macros are provided skeletal default code that basically does nothing. Click on the Edit button. The OCLC Connexion Macro Editor and Debugger should now appear with the default code as shown below.

The first two lines of code are comment statements. Comment statements always start with a single quote. A single quote should start each line that is intended to be a comment. Comment statements are like notes to help the user understand what this macro does. Connexion supplies default comment statements based on what you named your macro and the description you gave. Comment statements are not executed when your macro is run. You are welcome to put in as many comment statements you like.
Under the comment statements are four lines of code. If you are not a programmer, it isn't important to know what they mean, just that they are always provided in the default code Connexion supplies and they must never be deleted. If you delete them, your macro will never work.
Step 8: In order to get our macro to insert a 500 Index Note into a bibliographic record, we need to add one line of code. Type in a new line of code just before the "End Sub" statement and after the "Set CS ..." statement as shown below.

So, what does that line of code you just typed in do? The first part of the code is the command (CS.AddField). This tells Connexion that you want to add a field to the bibliographic record that is displayed in the client.
The next part of the code consists of two parameters that are sent to Connexion with the command. The first parameter indicates where among other 500 fields, the new 500 field should be inserted. In our macro, we gave it the number 1. This means that the 500 field we are inserting will be the first instance if there are other 500 notes in the record.
The second parameter is the actual field data to send to Connexion. It is separated from the first parameter by a comma. Without the comma, an error would occur. The field data should be surrounded by quotation marks (i.e., it is considered a text string). The field data should contain the first three numbers of the MARC tag (500), followed by the values of the indicators (two blanks), then the actual data of the field (Includes index.).
Step 9: Click on the save button. It is the third button from the left on the toolbar. It will contain an icon of a blue floppy disk. Then close the editor.
Your macro is finished. In order to get it to work, there are three possible ways to run the macro:
Note: You should also have a bibliographic or authority record displayed in the client. Without either, the macro will do nothing because there isn't a record to do anything to. Sometimes common sense prevails.
Note: If the field you are adding has subfield delimiters, see: OML Macros and Subfield Delimiters.
Note: You can have as many macros in your macrobook as you want. To add new ones, just highlight the name of the macrobook before pressing the New Macro button.
Yes, another note: The example above is for adding a 500 note to a bibliographic record. You can use the same code for adding fields to an authority record. In fact, if you ran the example 500 macro while an authority record is displayed, it will insert it into the authority record. Keep this in mind when you are running these macros nilly-willy to help prevent giving your NACO record checker headaches.