7.5

Table Of Contents
Talk Editor.
l Indent Use indents to visually represent the structure of the script. For example, indent the commands a loop struc-
ture encloses to make it apparent where the loop begins and ends.
l Comments Include meaningful comments in your code to make it easier to read and maintain.
Code Samples
This section presents short samples of PlanetPress Talk code that may be useful, and that may also stimulate your imagination
for the ways in which you can use PlanetPress Talk in your documents. Consult the PlanetPress Talk Language Ref-
erence for help understanding specific commands.
l "Print a variable number of copies of a page based on a value in the datastream" (page 240)
l "Store two lines of input data on one line of the data page" (page 240)
l "Print a page n-up" (page n)
l "Print a line of text on odd-numbered pages" (page 241)
l "Determine the proper page to print based on the width of the data in the data page" (page 242)
Print a variable number of copies of a page based on a value in the datastream
This sample prints a variable number of copies of a page based on an integer value in the data stream. It uses a global integer
variable &nbPage that is initialized to 0, and subsequently set to the value of the data that appears on line 1, columns 1
through 2 of the data page.
The document for which it was written uses two pages: DATA and RUNPAGE. DATA is an overlay page that contains all of the
data selections for the document. RUNPAGE is a runpage and the code that appears here is in a PlanetPress Talk object on
RUNPAGE.
% ====================================================
% PRINT A VARIABLE NUMBER OF COPIES OF A PAGE BASED ON
% A VALUE IN THE DATA STREAM
% ====================================================
if(ne(&printermode,0))
set(&nbPage,strtoint(@(1,1,2)))
define(&it,integer,0)
for(&it,1,1,strtoint(@(1,1,2)))
execpage('DATA')
showpage()
endfor()
endif()
Notes:
l The if(ne(&printermode,0)) statement prevents the program from executing during design.
l The local variable &it is a counter.
Store two lines of input data on one line of the data page
This sample is a user-defined emulation that reads two lines of input data, concatenates them, and stores them as a single line
in the data page buffer. It terminates a data page when it encounters a form feed character. The emulation relies on two
global variables:
©2010 Objectif Lune Inc - 240 -