Macros, the deeper workings, The nisus writer pro macro language, Old and new macros – Nisus Writer Pro User Manual

Page 421: Menu command dialect, 401 r

Advertising
background image

Macros, the Deeper Workings

The Nisus Writer Pro Macro Language

Writing macros is a form of programming.

!

The Nisus Macro Reference is distributed in the download with the application and the User's Guide.
It details all features of the macro language. You can learn more at <

http://nisus.com/pro/

macros>.
The Nisus Writer Pro macro language consists of various sets of instructions. Each individual macro
is made up of a list of these instructions that run in sequence (from top to bottom).
The simplest macros are made of Nisus Writer Pro menu commands… the actual commands you
see in the menus as illustrated in “Working with Menu Commands” on 307. While most of these
standard menu commands do exactly, and only, what they do when you choose them individually
from the menus, some can accept “arguments” that extend their meaning and capabilities.
Additional instructions exist that enable you to assign “values” (or to use a non-technical term
“meanings”) to “variables”. Other instructions offer the ability to direct the macro to “branch off” in
different directions if certain conditions are met.
Each individual paragraph of a macro file represents one complete instruction.
Nisus Writer Pro ignores any line in a macro that begins with the “#” character. You can use these
lines as comments to explain what the macro does. So, for example you might write the macro in
“Working with Menu Commands” on page 400 (of course you can put your comments either before
or after the command they deal with):

#Select the entire document.
Select All
#Apply the font Lucida Grande.
Lucida Grande
#Make it all bold.
Bold
The Nisus Writer Pro macro language has two “dialects”:

Menu Command Dialect (explained on page 401)

Perl Dialect (explained on page 416).

Old and New Macros

Nisus Writer Pro macros have many new features. These differ from the capabilities of Perl macros
which are also available in Nisus Writer Express (and Nisus Writer Pro). Nisus Writer Pro macros
can include any number of Perl and Menu Command blocks

16

. Perl macros can only use Nisus

Header blocks to execute some menu command lines, while the remainder must be Perl code.
With the Nisus Writer Pro macro language, the old Nisus Perl macros of Nisus Writer Express are no
longer needed. You can continue to use Perl macros for backward compatibility. It is difficult to
preserve text and paragraph attributes in Perl macros, but Nisus Writer Pro macros, using the
Menu Command Dialect, can easily preserve and control almost all text attributes.

Menu Command Dialect

The Menu Command dialect makes available every command of Nisus Writer Pro. It can extend
certain menu commands with additional options to include “parameter arguments” which tell the
program how to perform a particular menu command’s action.

!

Many such arguments must be inside quotes (as explained in “Using parameters with menu
commands” below)
unless they are a number, or a string variable.
When these parameters are omitted the menu commands will work just as if you had chosen that
command from the menu using the mouse or trackpad or a keyboard shortcut.

16

That is, a “statement block” or “code block”, a unique “message” that tells Nisus Writer Pro what to do. It may be

as short as a one-line paragraph or consist of a collection of nested tasks.

Advertising