rduncan10
16th March 2011, 17:16
I have a problem where some variables created in a report script don't print correctly when the user prints the report to Display (using a Screen printer). They do work when the user uses any other type of printer.

Report Script

declaration:
extern domain tcamnt rpt.total

detail.1:
before.layout:
if [condition is met] then
rpt.total = rpt.total + detail.total
endif
lattr.print = false


"rpt.total" is then added to the "after.report" section. If printed to display, this shows $0. If printed elsewhere, it shows the correct amount.

I usually try to avoid report scripts as much as I can. I admit I don't fully understand how to handle the variables here. I've tried various declaration methods, but nothing seems to work.

Thanks,
R

mark_h
16th March 2011, 17:36
What you show should work - I recommend setting the total to 0 in the before.program section. Second make sure that condition is set if going to screen or a printer. Then just put it in debug mode with the two different devices to see what is not executing correctly.

rduncan10
16th March 2011, 19:16
Thanks. Your suggestion about before.program pointed me in the right direction.

I forgot to show this in my sample, but I was resetting the variable in a "before.field" section. I had forgotten that this is fired whenever a new page is encountered. Our normal screen printer only shows a few lines, so new pages are encountered a lot.

I just put "if lattr.break then...endif" around the code that resets the variables and it works.

As I said, I usually try to avoid report scripts, so I forget these things.