Next: , Previous: , Up: DEFINE   [Contents][Index]


14.2.2 Introduction

The DEFINE command creates a macro, which is a name for a fragment of PSPP syntax called the macro’s body. Following the DEFINE command, syntax may call the macro by name any number of times. Each call substitutes, or expands, the macro’s body in place of the call, as if the body had been written in its place.

The following syntax defines a macro named !vars that expands to the variable names v1 v2 v3. The macro’s name begins with ‘!’, which is optional for macro names. The () following the macro name are required:

DEFINE !vars()
v1 v2 v3
!ENDDEFINE.

Here are two ways that !vars might be called given the preceding definition:

DESCRIPTIVES !vars.
FREQUENCIES /VARIABLES=!vars.

With macro expansion, the above calls are equivalent to the following:

DESCRIPTIVES v1 v2 v3.
FREQUENCIES /VARIABLES=v1 v2 v3.

The !vars macro expands to a fixed body. Macros may have more sophisticated contents:

Many identifiers associated with macros begin with ‘!’, a character not normally allowed in identifiers. These identifiers are reserved only for use with macros, which helps keep them from being confused with other kinds of identifiers.

The following sections provide more details on macro syntax and semantics.


Next: Macro Bodies, Previous: Overview, Up: DEFINE   [Contents][Index]