Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

PageMaker Scripting FAQ – Getting Started with Basic Scripting

A. How does scripting work?

PageMaker 6.x vastly improved upon PageMaker 5’s non-existent scripting interface. In PageMaker 5, you had to choose the “Run Script” addition and select the script you wished to run, which meant finding the file on your hard drive. PageMaker 6.x actually gives you a scripting palette where just double-clicking on a script runs it. The scripts are divided into subdirectories that mirror the contents of the “Scripts” folder on your hard drive. Creating, editing, and running scripts is quick and easy using the handy palette. Mucho better!

PageMaker scripts are made up of commands followed by arguments (also called parameters), which are the settings for that particular command. Not all commands have arguments. For instance, the command “deleterulerguides” simply deletes all guides on the current page of the current document. It doesn’t need any parameters. On the other hand, an instruction like “view” (which sets the current magnification level) requires you to tell it the percentage of zoom you’d like: a number between 25 and 800. Therefore “View 250” would zoom in to 250%.

Arguments are separated from the command by a space. Some commands require several arguments. Each argument is separated from the next by a comma and/or a space. Take, for example, the follow script:

removepages 4, 7

The above line would delete pages 4 through 7 of the current document. The “removepages” command takes two arguments, both numbers: the starting and ending page numbers of the range of pages to delete. Simple!

Every PageMaker command has its own list of arguments PageMaker expects to follow the command. If you do not have the right number of arguments, or the information in the arguments is the wrong type (some text instead of a number, for instance), PageMaker will give you a script error and halt execution of your script. It can often be difficult to figure out why a script isn’t working — make sure you are typing the commands exactly as intended and that the number of arguments you are including matches what PageMaker is expecting.

PageMaker is rather picky about its scripting language: everything must be exactly right or it will not work. Remember this is a computer you are working with — it only does what you tell it. If you tell it the wrong thing, it won’t know it. Here are few important tips to keep in mind when you are scripting:

Notice that the command “removepages” has no spaces in it. This is important. All PageMaker scripting commands are one word (no spaces).

PageMaker commands are not case sensitive. The instruction “removepages” is the same as “RemovePages” or “REMOVEPAGES“. Arguments to a command, however, often contain case sensitive material. When specifying a color, for example, “pms300” is not the same as “PMS300“.

You can send PageMaker more than one command per line, although it makes editing more difficult. Each command must be separated by a semicolon (;). For example: “page 1; view 75; page 2; view 75” is a valid script.

Scripts operate on the current open document. Make sure you are working with the correct document.

It is very easy to make mistakes in your scripts. Always work on an extra copy of your PageMaker document — your script potentially could goof up your document by moving or deleting the wrong object or page.

Make frequent use of the comment function: if PageMaker sees two hyphens as part of a script, it ignores the rest of that line. You can use this to help remind you what you are doing in that portion of a script. For example:

-- jumps to the master page
page rm
-- selects and deletes everything
deselect
-- we do this to chose the pointer (arrow tool)
selectall
clear

Specify the measurement unit within your script. Just like you can in PageMaker’s dialogs or control palette, you can specify the measurement unit you’d like to use by appending an “i” or “p” or “m” next to the number. For instance, “5i” is five inches. “5p6” is five and a half picas. “6m” would be 6 millimeters. Note that there should be no space between the measurement unit and the numbers.

The next section contains some sample scripts for you to try.

B. How do I install your scripts into PageMaker?

PageMaker 6.5 has a revamped scripting interface that makes it easy to add, edit, and delete scripts. In all versions of PageMaker that support scripting (4.2 or better), scripts are stored in a “Scripts” folder inside the PageMaker folder. In PageMaker 6.5 the “Scripts” folder was moved into the “Plugins” folder (which is inside the “RSRC” folder).

The “Scripts” folder is an ordinary directory on your hard drive — you can place files inside it or delete items from it as you will. All script files are ordinary “plain text” files — that is, they contain no word processor formatting codes. This means the files are the same for Macintosh and PC systems, and the files can be posted via the Internet or E-mail without worry of losing details. Most word processors let you save a file as “plain text” — look for that option when you save the file. On the Macintosh, I like to use the freeware program BBEdit Lite, a simple but powerful text editor to edit my PageMaker scripts. (Because BBEdit is a text editor, not a word processor, I don’t have to worry about saving the file in any special format — in fact, I leave the file open and switch between PageMaker 6.5 to test my script, and BBEdit to edit it.)

Starting with PageMaker 6, PageMaker has a floating scripts palette which makes it easy to select and execute scripts:

scriptspalette picture

The contents of the “Scripts” palette match the contents of the “Scripts” folder exactly. You can add, delete, or rearrange folders and scripts as you like. Use the triangle icon at the upper right of the palette to access the script submenu. It lets you create folders, new scripts, or edit the selected script. My favorite shortcut is command-clicking on a script brings up PageMaker’s script editing dialog (control-click on the PC).

To install scripts from the PageMaker Scripting Center, you can copy and paste the scripts into new documents, or use your web brower’s “Save” function to save the script as a text file (not as HTML source). Be sure to save the file in PageMaker’s “Scripts” folder.

In PageMaker, you can create a new script by choosing “New Script” from the submenu, give it a name and save it in the appropriate folder, and then paste in the text copied from your web browser.

C. Can I see some simple scripts?

PageMaker scripting is really very simple. The commands are English-like and most mimic the names of the menu commands which perform the same functions. For example, the “bringtofront” command is the same as choosing “Bring to front” from the element menu.

Here are some sample scripts which you can try. Simply copy the text of each script and save it as a text file on your computer. If you are using PageMaker 5, you can run the script with the “Run Script” Addition (off the “Utilities” menu).

In PageMaker 6.x you can copy this script to the clipboard and use the “New Script…” command (off the script palette’s submenu) to create a new script. Save the script in an appropriate subfolder within the “Scripts” folder and give it an appropriate name. After saving the file, paste the copied text into the window that is displayed. Click “OK” to save the script. To run it, just double-click on the scripts name. To edit the script, select it (one click) and choose “Edit Script” off the script palette’s submenu. You can also command-click (Mac OS) or control-click (Windows) the script to edit it (just like you edit a style or color).

-- Business Card Guides 
-- by Marc Zeedar 8/96
-- Sets up 8-up business card template on 8.5x11 page
new 1
pagesize 8.5i, 11i
pageoptions off, off
pagemargins .75i, 1.5i, .75i, 1.5i
zeropoint .75i, 1.5i

guidehoriz 0i
guidehoriz 2i
guidehoriz 4i
guidehoriz 6i
guidehoriz 8i
guidevert 0i
guidevert 3.5i
guidevert 7i
zeropointreset
-- end of script

-- 1" Grid Guides
-- by Marc Zeedar 8/96
-- Sets up 1" vertical grid on *existing* page
-- (assumed to be 8.5x11)
zeropointreset
guidehoriz 1i
guidehoriz 2i
guidehoriz 3i
guidehoriz 4i
guidehoriz 5i
guidehoriz 6i
guidehoriz 7i
guidehoriz 8i
guidehoriz 9i
guidehoriz 10i
-- end of script

-- 0.5" Grid Guides
-- by Marc Zeedar 8/96
-- Sets up 0.5" vertical grid on *existing* page
-- (assumed 8.5x11)
zeropointreset
guidehoriz .5i
guidehoriz 1i
guidehoriz 1.5i
guidehoriz 2i
guidehoriz 2.5i
guidehoriz 3i
guidehoriz 3.5i
guidehoriz 4i
guidehoriz 4.5i
guidehoriz 5i
guidehoriz 5.5i
guidehoriz 6i
guidehoriz 6.5i
guidehoriz 7i
guidehoriz 7.5i
guidehoriz 8i
guidehoriz 8.5i
guidehoriz 9i
guidehoriz 9.5i
guidehoriz 10i
guidehoriz 10.5i
-- end of script

This one was distributed by Aldus with old versions of PageMaker.

-- Aldus Corporation 1993
-- Fraction script
-- Selects and reformats the denominator
textselect -word
typeoptions 80,58,33,0
-- Size and position can be adjusted for better
-- results with different fonts
position subscript
textcursor -char
-- Selects and changes normal slash
-- to opt shift 1 fraction slash (Mac only)
textselect 0 textenter "/"
--Selects and reformats the numerator
textcursor -char
textselect -word
typeoptions 80,58,33,0
position superscript
--Leaves cursor where you started
textcursor +word 2
position normal
redraw on
-- end of script

D. What about something more complicated?

These scripts are little longer and do a bit more. Hopefully you will find them useful. You can easily modify them to suit your needs, especially if you are an international user and need to change the paper size as appropriate for your county.

This first script creates a new document and draws guides appropriate for a tri-fold brochure, making sure that the inside panel is shorter than the two outside panels. It adds labels to the cover panel on page 1 and the short panel on page 2 so you don’t forget which is which. This version of the script assumes .5 inch margins, but you could easily change that. (You’d have to modify both the “pagemargins” line and the guides on either side of the center guides.)

-- Creates tri-fold brochure template
-- (8.5i x 11i folded in thirds)
-- uses 1/2 inch margins
-- by Marc Zeedar 8/96
new 2 pagesize 11i, 8.5i
pageoptions off, off
pagemargins .5i, .5i, .5i, .5i
page 1
-- draws guides between left and middle panels
guidevert 3.125i
guidevert 3.625i
-- Center. Guides on either side are .5" less/more
guidevert 4.125i
-- draws guides between middle and right panels
guidevert 6.8125i
guidevert 7.3125i
-- Center. Guides on either side are .5" less/more
guidevert 7.8125i
newstory 1i, 7.5i
textenter "COVER PANEL"
deselect
select 1
resize left, 7.8125i
page 2
-- draws guides between left and middle panels
guidevert 3.1875i
guidevert 3.6875i
-- Center. Guides on either side are .5" less/more
guidevert 4.1875i
-- draws guides between middle and right panels
guidevert 6.875i guidevert 7.375i
-- Center. Guides on either side are .5" less/more
guidevert 7.875i
newstory 1i, 7.5i
textenter "SHORT PANEL"
deselect
select 1
resize left, 7.875i
-- end of script

Comments