IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#47703 - 05/01/14 10:56 AM Adding Numbers in Data Selection
Angela Offline
OL Newbie

Registered: 05/01/14
Posts: 2
I have inserted a data selection in Design that contains a list of numbers. I need to add a total at the bottom. Can someone help me with the code I need to enter to get it to add all of the numbers in the selection? Thanks!

Top
#47756 - 05/07/14 08:53 AM Re: Adding Numbers in Data Selection [Re: Angela]
jim3108 Offline
OL Expert

Registered: 04/19/10
Posts: 316
Loc: London, UK
To do this, simply loop over each line.
If it is a line printer (txt) incoming file then do the following:

Set up a global variable from the left hand document structure menu called "total".

Then you need to create a run page - create a new page which is at the top of the document tree and change its properties so that "page ejects" is unchecked.

Drop a PressTalk object on the page which has this code in it:

Code:
for(&current.line, 1, 1, 66)
    &total := &total + @(&current.line, startpos, endpos)
endfor()

* I am assuming it is a standard 66 line file - we can change this if necessary.
* Replace 'startpos' and 'endpos' with the start and end character of the total on any line.

Now on a normal page (on which you want the lines to show):

Create a data selection object on the page and in the properties, tick "Custom data selection" and make your custom data selection equal as follows:
Code:
=inttostr(&total)


You could then set a condition on the object to only show on the page on which you want the total to appear.

Let me know how you get on.


Edited by jim3108 (05/07/14 08:55 AM)

Top
#47796 - 05/08/14 03:19 AM Re: Adding Numbers in Data Selection [Re: Angela]
Dal Offline
OL Guru

Registered: 08/29/08
Posts: 114
Loc: UK
If you want a line loop to run the entire length of a data page, you should replace the number 66 in your for declaration to &Current.lpp.

This would prevent the code from 'breaking' if the length of the data page was changed.


Edited by Dal (05/08/14 03:27 AM)

Top