5.2 Commands

Document: BTXHAK ["Designing BibTeX Styles" by Oren Patashnik]


next 5.3 The built-in functions
up 5 Bibliography-style hacking
gif 5.1 General description

5.2 Commands

There are ten style-file commands: Five (ENTRY, FUNCTION, INTEGERS, MACRO, and STRINGS) declare and define variables and functions; one (READ) reads in the database information; and four (EXECUTE, ITERATE, REVERSE, and SORT) manipulate the entries and produce output. Although the command names appear here in upper case, ignores case differences.

Some restrictions: There must be exactly one ENTRY and one READ command; the ENTRY command, all MACRO commands, and certain FUNCTION commands (see next subsection's description of call.type$) must precede the READ command; and the READ command must precede the four that manipulate the entries and produce output.

Also it's best (but not essential) to leave at least one blank line between commands and to leave no blank lines within a command; this helps recover from any syntax errors you make.

You must enclose each argument of every command in braces. Look at the standard-style documentation for syntactic issues not described in this section. Here are the ten commands:

ENTRY
Declares the fields and entry variables. It has three arguments, each a (possibly empty) list of variable names. The three lists are of: fields, integer entry variables, and string entry variables. There is an additional field that automatically declares, crossref, used for cross referencing. And there is an additional string entry variable automatically declared, sort.key$, used by the SORT command. Each of these variables has a value for each entry on the list.

EXECUTE
Executes a single function. It has one argument, the function name.

FUNCTION
Defines a new function. It has two arguments; the first is the function's name and the second is its definition. You must define a function before using it; recursive functions are thus illegal.

INTEGERS
Declares global integer variables. It has one argument, a list of variable names. There are two such automatically-declared variables, entry.max$ and global.max$, used for limiting the lengths of string variables. You may have any number of these commands, but a variable's declaration must precede its use.

ITERATE
Executes a single function, once for each entry in the list, in the list's current order (initially the list is in citation order, but the SORT command may change this). It has one argument, the function name.

MACRO
Defines a string macro. It has two arguments; the first is the macro's name, which is treated like any other variable or function name, and the second is its definition, which must be double-quote-delimited. You must have one for each three-letter month abbreviation; in addition, you should have one for common journal names. The user's database may override any definition you define using this command. If you want to define a string the user can't touch, use the FUNCTION command, which has a compatible syntax.

READ
Dredges up from the database file the field values for each entry in the list. It has no arguments. If a database entry doesn't have a value for a field (and probably no database entry will have a value for every field), that field variable is marked as missing for the entry.

REVERSE
Exactly the same as the ITERATE command except that it executes the function on the entry list in reverse order.

SORT
Sorts the entry list using the values of the string entry variable sort.key$. It has no arguments.

STRINGS
Declares global string variables. It has one argument, a list of variable names. You may have any number of these commands, but a variable's declaration must precede its use.

Document: BTXHAK ["Designing BibTeX Styles" by Oren Patashnik]


next 5.3 The built-in functions
up 5 Bibliography-style hacking
gif 5.1 General description



WebMaster@eeng.dcu.ie
Wed May 15 11:28:03 GMT 1996