Internal Scripts

Using scripts inside PageStream? Not sure this should just remain only in the PageStream user reference.

 

Internal Scripts  Chapter  url:PGScmd/Cinternal
  created:2006-03-31 14:53:34   last updated:2006-08-16 19:37:20
  Copyright © 1985-2017 GrasshopperLLC. All Rights Reserved.

User Contributed Comments For Internal Scripts
Henry G Belot wrote...2006-04-25 06:48:14

Quote:

Using scripts inside PageStream? Not sure this should just remain only in the PageStream user reference.

It seems to me that raising a question, pushes us beyond "documentation" and into User Forum land, but I understand the problem. I would recommend that "internal scipts" be called "PageStream Macros" and "external scripts" be called "external scripts" or just "scripts." This is mostly a matter of experience. Lots of programs have macros and macro recorders of one sort or another for automating repetitive tasks that are replications of your interaction with the program. They are generally called "macros." That's the term I'm accustomed to seeing. When things get fancier, such as providing for live interaction during the execution of the routine, then they become "scripts."

To some extent you can go either way in PageStream. You can edit a macro to some extent, but at some point I believe you cross over a line and need Python or AREXX to get the job done. (Not having written in Python I'm not dead-on sure about that, but clearly if you didn't need an external programming language, there'd be no point in requiring either of these languages.) So, that's how I'd draw the line. An introduction might say something like:

"PageStream provides great flexibility for automating repetitive routines. Macros allow you to record a series of keyboard and mouse actions, save them, and repeat them from a menu or with a keyboard shortcut. You can also edit some aspects of a recorded macro. External scripts extend these capabilities considerably using the Python programming language or, optionally on the Amiga, AREXX. In this section we explain how to create and use PageStream macros. You do not need Python to do this."

Beyond the above, I'm not sure where else besides the PageStream User Reference you'd want to put this information. External scripts might be another matter.

HB

Tim Doty wrote...2006-04-25 16:33:30

Internal Scripts (Macros)

PageStream provides the ability to record what you do. This set of actions can then be "played" again and again to take the monotony out of repetitive tasks. When you close PageStream any new macros will be forgotten unless you save them first.


Example

If a project will have tables set off from the text that will have a certain appearance and format you can use a macro to ease generating them. In this case these tables will all be text frame objects. They are to have a 1-point black stroke outlining the box with a 50% pink fill and a 1/16" margin from each edge to the text. Other text should flow to all sides of the object with a 1/8" standoff.

To create a macro for this first create a text frame. It can be the first such object in the document or it can be a "dummy" that you will delete later. It needs to be just a text frame without any of the formatting previously described. Select this object with the object tool and choose Start Recording from the Scripts menu.

1. From the Object menu choose Line & Fill, set the line to a 1-point black and the fill to 50% pink. Okay the requester.

2. Again from the Object menu choose Frame/Text Frame Options and set the margins. Okay the requester.

3. Still from the Object menu choose Text Wrap, set the 1/8" margins and method 5. Okay the requester.

4. Finally selection Stop Recording from the Scripts menu.

The result should be the following:

Code:


DISPLAY OFFSET -0.3265i 0.4031i

BEGINLOCKCAPTURE LINEFILL

FILLED ON OBJECT

SETFILL BASIC FILL OBJECT

SETFPATTERN NONE FILL OBJECT

SETCOLORCOUNT 1 FILL OBJECT

SETCOLORSTYLE Pink COLORNUMBER 0 FILL OBJECT

SETCOLORTINT 50% COLORNUMBER 0 FILL OBJECT

SETCOLORBLEND NONE COLORNUMBER 0 FILL OBJECT

SETTRAPPING DEFAULT FILL OBJECT

SETSCREEN 4 DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT OBJECT

STROKED ON OBJECT

SETSTROKECOUNT 1 OBJECT

SETSTROKE SOLID STROKENUMBER 0 OBJECT

SETSTROKEOFFSET 0pt STROKENUMBER 0 OBJECT

SETSTROKEWEIGHT 0.5pt STROKENUMBER 0 OBJECT

SETSTROKEJOIN MITER 11° STROKENUMBER 0 OBJECT

SETSTROKEBEGIN FLAT STROKENUMBER 0 OBJECT

SETSTROKEEND FLAT STROKENUMBER 0 OBJECT

SETSTROKECAP BUTT STROKENUMBER 0 OBJECT

SETFILL BASIC STROKENUMBER 0 OBJECT

SETFPATTERN NONE STROKENUMBER 0 OBJECT

SETCOLORCOUNT 1 STROKENUMBER 0 OBJECT

SETCOLORSTYLE Black COLORNUMBER 0 STROKENUMBER 0 OBJECT

SETCOLORTINT 100% COLORNUMBER 0 STROKENUMBER 0 OBJECT

SETCOLORBLEND NONE COLORNUMBER 0 STROKENUMBER 0 OBJECT

SETTRAPPING DEFAULT STROKENUMBER 0 OBJECT

SETSCREEN 4 DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT DEFAULT OBJECT

ENDLOCKCAPTURE

SETTEXTFRAME COLUMNS 1 GUTTER 0.25i MARGINS 0.0625i 0.0625i 0.0625i 0.0625i

SETTEXTWRAP SHAPE STANDOFF 0.125i 0.125i WRAPAROUND

Wow! That's a lot of commands. We don't actually need all of them to do what we want. PageStream recorded everything from the requesters, even the things we didn't change. Give the macro a name, maybe SetBorder. Notice that you can set the script to run with a keypress if you want or tell PageStream to display it in the Scripts menu. You don't have to do either, though. If you open the Script Palette (from the Window menu) you can see all loaded macros. From there you can run a macro or edit it. You can also save the list of macros for future use.


Digging Deeper

Although it isn't really necessary the commands can be trimmed down to set just what we need. Doing so gives us the following:

Code:


BEGINLOCKCAPTURE LINEFILL

FILLED ON OBJECT

SETCOLORCOUNT 1 FILL OBJECT

SETCOLORSTYLE Pink COLORNUMBER 0 FILL OBJECT

SETCOLORTINT 50% COLORNUMBER 0 FILL OBJECT
SETCOLORBLEND NONE COLORNUMBER 0 FILL OBJECT

STROKED ON OBJECT

SETSTROKECOUNT 1 OBJECT

SETSTROKE SOLID STROKENUMBER 0 OBJECT

SETSTROKEWEIGHT 0.5pt STROKENUMBER 0 OBJECT

SETCOLORCOUNT 1 STROKENUMBER 0 OBJECT

SETCOLORSTYLE Black COLORNUMBER 0 STROKENUMBER 0 OBJECT

SETCOLORTINT 100% COLORNUMBER 0 STROKENUMBER 0 OBJECT

ENDLOCKCAPTURE

SETTEXTFRAME COLUMNS 1 GUTTER 0.25i MARGINS 0.0625i 0.0625i 0.0625i 0.0625i

SETTEXTWRAP SHAPE STANDOFF 0.125i 0.125i WRAPAROUND

Let's take a look at what these do.

BEGINLOCKCAPTURE LINEFILL

This tells PageStream that the following commands are going to modify the line and fill of the currently selected object(s).

BEGINLOCKCAPTURE LINEFILL

FILLED ON OBJECT

SETCOLORCOUNT 1 FILL OBJECT

SETCOLORSTYLE Pink COLORNUMBER 0 FILL OBJECT

SETCOLORTINT 50% COLORNUMBER 0 FILL OBJECT
SETCOLORBLEND NONE COLORNUMBER 0 FILL OBJECT

These commands turn the object's fill on, set the color, tint and blend.

STROKED ON OBJECT

SETSTROKECOUNT 1 OBJECT

SETSTROKE SOLID STROKENUMBER 0 OBJECT

SETSTROKEWEIGHT 0.5pt STROKENUMBER 0 OBJECT

SETCOLORCOUNT 1 STROKENUMBER 0 OBJECT

SETCOLORSTYLE Black COLORNUMBER 0 STROKENUMBER 0 OBJECT

SETCOLORTINT 100% COLORNUMBER 0 STROKENUMBER 0 OBJECT

These commands turn the object's line stroking on, set the line weight, fill style, color and tint.

ENDLOCKCAPTURE

This command lets PageStream know that the line and fill commands are done.

SETTEXTFRAME COLUMNS 1 GUTTER 0.25i MARGINS 0.0625i 0.0625i 0.0625i 0.0625i
This command forces the text frame to use a single column. If this is not desired simply remove the COLUMNS 1 portion of the line.

SETTEXTWRAP SHAPE STANDOFF 0.125i 0.125i WRAPAROUND
This final command tells PageStream to use "WrapAround" method of text flow (option 5 in the requester) with 1/8" standoffs. SHAPE specifies that the text is to flow around the shape of the object. So if this script were applied to an irregular text frame any surrounding text would flow around its shape.

User Contributed Comments For Internal Scripts