6.0

Table Of Contents
Code Samples
23
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 Reference for help understanding specific commands.
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.
Code
% ====================================================
% 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
• The if (ne (&printermode,0)) statement prevents the program executing during design.
• The local variable &it is a counter.