7.1
2013-09-23

Extended Scripting

Extended Scripting is a fast and flexible way of automating your print jobs. This feature allows you to print any PrintShop Mail document, combined with any database to any printer. You can even schedule an Extended Scripting job on a certain date and/or time where your printer is usually idle.

Automation features are no longer sold and are being deprecated. You may continue to use the features, however new dongles are not shipped with these features enabled, and no upgrades are possible with this feature enabled. Automation features are now available by combining PrintShop Mail with the power of PlanetPress Workflow Tools, part of PlanetPress Suite.

You specify a certain action, or a range of actions, in a plain text file and tell PrintShop Mail to use that file by adding it to a shortcut:

  1. Create a shortcut to the PrintShop Mail executable usually located at "C:\Program Files\PrintShop Mail6\PSMail6x.exe".

  2. Add "-script scriptfile.txt" to the Target in the properties of the shortcut.

Note: When the script file has a name with spaces ("My<space>Script.txt") be sure to enclose this file name with quote marks ("") in the Target line of the PrintShop Mail shortcut: "C:\Program Files\PrintShop Mail 6\PSMail6x.exe” -script “My Script.txt”. Include the quote marks if you copy this line.

In the script you can specify a set of predefined commands to perform certain actions.

Supported Commands

Command

Description

FileOpen [name]

Opens the specified document. If another document is opened, it will be closed by PrintShop Mail.
Example: FileOpen C:\Documents\MassMailing.psmd

FileClose

Closes the currently opened document. 

FilePrint

Prints the currently opened document to the default printer selected in the PrintShop Mail document properties. 

FilePrintTo [printername]

Prints the currently opened document to the specified printer.

The name of the printer should equal the name specified in the Printer's properties.

Example: FilePrint MyPrinter

FilePrintToFile [filename] Prints the currently opened document to the specified file. If its print technology would create multiple files, FilePrintToFile will generate a zip file.

SetPrintTech [technology]

Will change the current print technology.

Example: SetPrintTech Standard

FilePrintRange [start] [stop]

Prints the specified record range to the default printer selected in the PrintShop Mail document properties.

Note: It is not possible to print a record range to a non-default printer.

Example: FilePrintRange 5 10 Prints record 5 to 10 from the currently opened document.

FileExit

Quits PrintShop Mail. No other scripting commands followed by this command are executed. 

DatabaseOpen [file]

Opens the specified database. If any other database is opened, it will be closed by PrintShop Mail. If the database contains multiple tables, DatabaseOpen will automatically select the first table. You can then use DatabaseSelectTable to select a different table.

Example: DatabaseOpen C:\Documents\Example.mdb

Opens the Microsoft Access database "Example" from the folder C:\Documents.

DatabaseOpenODBC [source]

Opens the specified data source. If any other database is opened, it will be closed by PrintShop Mail.

Example: DatabaseOpenODBC MyDSN

Opens the data source called "MyDSN"

DatabaseSelectTable [table name] Selects a different database table in the currently opened document.

DatabaseFilter [filter]

Filters the database according to the specified filter.

Example: DatabaseFilter [CITY] = 'New York'

Filters the database, only records where the value of field "CITY" equals "New York" will be used.

DatabaseClose

Closes the currently opened database.

Example: DatabaseClose

The argument <technology> must have one of the following predefined values.

Print Technology

Script Value

Standard PostScript

SetPrintTech Standard

Optimized PostScript

SetPrintTech Optimized

Adobe PDF SetPrintTech PDF
Adobe PDF/VT1 SetPrintTech PDF/VT1

AHT

SetPrintTech AHT

Creo VPS

SetPrintTech VPS

FreeForm

SetPrintTech FreeForm

FreeForm2

SetPrintTech FreeForm2

PPML

SetPrintTech PPML

PPML/VDX

SetPrintTech PPMLVDX

VIPP

SetPrintTech VIPP

How do I create an Extended Scripting job?

You create an extended scripting job by following the next steps:

  1. Create a PrintShop Mail document and save it, for example "ScriptTest.psmd".

  2. Create a textfile containing all commands you want to perform.

  3. Create a shortcut to PrintShop Mail.

  4. Add the argument "-script scriptfile.txt" to the command line (where "scriptfile.txt" is the textfile containing the commands)

Note: It is advised to save your script file as "UNICODE" encoding.

Note: Automated printing allows you to print PrintShop Mail documents and PrintShop Mail templates automatically through the Command line or script file . Make sure to use the appropriate extension (<document name>.psmd or <document name>.psmt) in the Command line or in the script file.

In the script file, you specify all commands you want to perform:

FileOpen ScriptTest.psmd
FilePrint
FileExit

This simple scriptfile opens the document "ScriptTest.psmd", prints it to the default printer and quits PrintShop Mail.

You can create a batch process by telling PrintShop Mail to use another document:

FileOpen ScriptTest.psmd
FilePrint
FileOpen AnotherDocument.psmd
FilePrint
FileExit

PrintShop Mail first opens the document, "ScriptTest.psmd" and prints it to the default printer. When this is done, PrintShop Mail opens the second document, "AnotherDocument.psmd" and prints it to the same default printer. Of course, you can choose to specify a different printer by using the command "FilePrintTo". Finally, PrintShop Mail exits.

It's possible to use the same document with different databases:

FileOpen ScriptTest.psmd
FilePrint
DatabaseOpen AnotherDatabase.MDB
FilePrintTo Printer2
FileExit

This opens the document "ScriptTest.psmd" and prints it to the default printer. When this is done, PrintShop Mail opens the database "AnotherDatabase.MDB" and prints it to another printer, called "Printer2". Finally, PrintShop Mail exits.

A combination of the commands is also possible:

FileOpen ScriptTest.psmd
FilePrintRange 5 10
DatabaseOpen AnotherDatabase.MDB
FilePrintRange 10 15
DatabaseOpen ThirdDatabase.XLS
FilePrintTo Printer2
FileOpen Document2.psmd
FilePrint
FileExit

This opens the PrintShop Mail document "ScriptTest.psmd" and prints records 5 to 10 to the default printer. When this is finished, it opens the database "AnotherDatabase.MDB" and records 10 to 15 are printed to the default printer. Then, the database "ThirdDatabase.XLS" is opened and all records are printed to printer "Printer2". Eventually, the PrintShop Mail document "Document2.psmd" is opened, printed to the default printer and PrintShop Mail exits.

It's possible to change the Print Technology used when the document was created, or print the same document using different Print Technologies:

FileOpen ScriptTest.psmd
SetPrintTech Optimized
FilePrint
FileOpen ScriptTest.psmd
SetPrintTech Standard
FilePrint
Database Filters

A database filter consists of a field name, an operator and a condition. Suppose you have the following database:

NAME

CITY

GENDER

Eddy

New York

M

Pamela

Los Angeles

F

Tim

Washington

M

Robert

New Jersey

M

The available field names in this database are "Name", "City" and "Gender". The database has 4 records.

An operator should be one of the ANSI SQL operators listed in the table below.

Operators

Definition

=

Equal

<>

Not equal

<

Less than

>

Greater than

<=

Less than or equal

>=

Greater than or equal

A filter is used to construct the WHERE clause of an SQL statement. It does not include the reserved word WHERE to filter the record set.

Except for "Distinct", "Like" and "Between", all SQL commands are supported. For more information about the SQL commands, please visit www.sql.org.

If you want to select and print the records where the field name "City" equals "New York", the following line should be added to the script file:

DatabaseFilter [CITY] = 'New York'

Result: One record will be printed.

Note: Please notice that we have used single quotes around the conditional values 'New York'. SQL uses single quotes around text values. Numeric values should not be enclosed in quotes.

Suppose you want to send a mailing to all persons in the database where [GENDER] does not equal 'F'. The filter should look like:

DatabaseFilter [GENDER] <> 'F'

Result: Three records will be printed.

Or, you want to print all records where the [GENDER] equals 'F' OR where [CITY] does not equal 'Washington':

DatabaseFilter [GENDER] = 'F' OR [CITY] <> 'Washington'

Result: Three records will be printed

These are just three examples of a database filter. You can create very advanced and powerful database filters. Please refer to your SQL manual or an online resource for advanced examples.

If you need to have data from more than one table in the database, you can make a query in SQL or MS Access and export the result of this query into Excel, Access or a text file. This file can be used as a database in PrintShop Mail.

Scheduling a job

It is possible to schedule a certain job on a certain date and time. This can be achieved by using the Windows Scheduler. For more information about the Windows Scheduler and how to create a scheduled task, please refer to your Microsoft Windows® manual.