If you are new to programming commands and queries, 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.
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 command callback to PageMaker -- executing its behavior -- is performed in the constructor using any parameters that the constructor required.
One consequence of this is that creating command objects may cause an exception to be thrown if PageMaker is unable to perform the command for some reason. You should always
Because the only public interface to command objects is their constructor(s), they 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, a PNew object is assigned a variable name (newPub), which is unnecessary. The briefer version, PNew(5), accomplishes the same thing without a name. This more concise style 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 specifying 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.
![]() |
Comments or suggestions? Contact Adobe
Developer Support Copyright © 1997 - 2001 Adobe Systems Incorporated. All rights reserved. Legal notices and trademark attributions |