Command class overview

If you are new to programming with the PageMaker Class Library, this section contains some useful information about command classes. You should also review the query class overview for information about query classes.

Command classes are C++ classes that perform a command callback to PageMaker. They are used in PageMaker plug-ins to perform actions in PageMaker. Typical commands include creating a new publication, setting its page size, creating text and graphical objects in the publication, and so forth. Nearly any action a user can perform with PageMaker menus, dialogs, or directly in the publication window can be effected with command objects.

Nameless command objects

As C++ classes, command classes all share one interesting characteristic: the only interface to command classes are their constructors. The only thing you can do to a command class is create it. Once it has been created, its job is done. The callback to PageMaker is performed in the constructor using any parameters that the constructor required.

Because of this somewhat unique characteristic, command classes can be written in a slightly unusual style.

Normally, when programming in C++, every object that you create is assigned to a variable name. However, the C++ language permits you to omit a variable name, in which case you can never refer to that object again directly after it is created. Since command objects do nothing after being created, this permits a useful shortcut when programming.

Below, the PNew object created is assigned to a variable name (newPub), which is unnecessary. The briefer version, PNew(5), accomplishes the same thing without a name. This shorter version is used throughout the programming examples in this documentation.

Using this programming style, command objects resemble ordinary function calls, however an object is being created and initialized. Unlike an ordinary function, when the object goes out of scope, the destructor for the object is called, releasing any memory used by the command object. There is no harm is providing variable names for command objects, although it provides no benefit and just increases your programming effort.

While command objects can (and should) be nameless, query objects never are. With query objects, you need a variable name to access the query results returned by PageMaker. Refer to the query class overview for more information about query objects.


Copyright © 1996, Adobe Systems Incorporated. All rights reserved.

Comments or suggestions? Contact Adobe Developer Support