Rancor Macro Language

From Koha Wiki
Jump to navigation Jump to search

This document describes the basic syntax of the macro language for Rancor (the professional cataloging editor, see bug 11559).

Examples

new 500=‡aEdited with Rancor
Creates a new 500 with a ‡a subfield and sets it to "Edited with Rancor".
245c= by J.K. Rowling.
Sets the first ‡c subfield of the first 245 tag in the record to " by J.K. Rowling", creating it if necessary.
082a={084a}
Sets the ‡a subfield of the first 082 tag (creating the subfield if necessary) to the contents of the first 084‡a.
indicators=_1
Sets the indicators of the last mentioned tag (in this case, 082) to "_" and "1".
new 090a=Z674.75.W67
Creates a new ‡a subfield on the first 090 (but only if that field already exists) and sets it to Z674.75.W67.
new 090a at end=Z674.75.W67
Same as above.
new 245b after a= a tale of might and magic /
Creates a new ‡b after the first a subfield and sets it to " a tale of might and magic /".
delete 245b
Deletes the first ‡b subfield on the first 245 to ‡b

Basic syntax

The macro language has two basic commands: delete TARGET and TARGET=VALUE.

A macro is just a sequence of commands.

Commands

TARGET=VALUE

Sets TARGET to VALUE. VALUE can be just text, like so:

245c=Harry Potter and the sorceror's stone /

Or bring in values from other parts of the record:

245c={300a} [automatically added]

(See "Sources" for what can go between the curly braces.)

delete TARGET

Deletes TARGET. For instance, this deletes the first 100 field:

delete 100

Targets

Rancor supports the following targets, all of which work with assignment (TARGET=VALUE) and some of which work with delete.

Fields

### (e.g., 245)
Sets the entire contents of the first matching field, possibly including indicators. Creates the field if it does not exist. Can be deleted.
new ### (e.g., new 300)
Sets the entire contents of a new field with the given tag (will be inserted in sorted order).
new ### grouped (e.g., new 610 grouped)
Same as above, but the new field is inserted at the end of the given group (610, for example, would be inserted after all 6xx tags).

Subfields

###x (e.g., 245a)
Sets the contents of the first matching subfield on the first matching field. Creates the subfield if it does not exist. Will fail if no matching field is found. Can be deleted.
new ###x or new ###x at end (e.g., new 952c)
Sets the contents of a new subfield created at the end of the first matching field. Will fail if no matching field is found.
new ###x after y (e.g., new 245h after a)
Sets the contents of a new subfield created after the first matching subfield on the first matching field.
$x, new $x or new $x after y (e.g., new $1)
Same as above, but apply to the last mentioned field. For instance, 245a=The best potato / followed by $c= by Donald Smith. would set both the a and c subfields of the first 245 field.

Indicators

### indicators (e.g., 020 indicators
Set the indicators of the first matching field.
indicators
Same as above, but apply to the last mentioned field.

Sources

### (e.g., 245)
The entire contents of the first matching field, including indicators.
###x (e.g., 245a)
The contents of the first matching subfield on the first matching field.