Application Module

Hello All;

I have the following script that is executed by a client timer script. It checks a flag every 15 seconds, if true run script:

[color=#0040FF]def printReport():
import system, app

print "Report print called"

def a():
import system
print “report Open called”
system.nav.openWindow(“Report PDF”)
print “report Opened”

def b():
	import system
	print "Report Printing"		
	win = system.gui.getWindow("Report PDF")
	win.getRootContainer().getComponent("Report Viewer").print(None, 0)
	print "Report should have printed"
	system.tag.writeToTag("Versa_Mill/Report_Ready_Flag", 0)
	system.nav.closeWindow("Report PDF")


system.util.invokeLater(b, 5000)

a()[/color]

The script only runs once after the client is first openned. You need to shutdown the client and re-open for it to work again.

Note: When the script runs it prints out the steps for the first execution. On subsequent attemps it only prints “Report print called”

Any thoughts as too why it will not execute on subsequent triggers?

We don’t have enough information. What is in your timer script?

Timer Script:

[color=#0040FF]from java.util import Date
import app, system
now = Date()
ts = system.db.dateFormat(now, “H:mm:ss”) # Report generation time

printFlag = system.tag.getTagValue(“Versa_Mill/Report_Ready_Flag”)

if printFlag == 1:
app.Print_Report.printReport()[/color]

Ok, I see what is going on. Essentially, the first time the script modules are loaded the functions a() and b() get called. After that you just call the app.Print_Report.printReport() function. You need to put the function call to a and b inside of the printReport function so it gets called every time.[code]def printReport():
import system, app
print “Report print called”
app.Print_Report.a()
app.Print_Report.b()

def a():
import system
print “report Open called”
system.nav.openWindow(“Report PDF”)
print “report Opened”

def b():
import system
print “Report Printing”
win = system.gui.getWindow(“Report PDF”)
win.getRootContainer().getComponent(“Report Viewer”).print(None, 0)
print “Report should have printed”
system.tag.writeToTag(“Versa_Mill/Report_Ready_Flag”, 0)
system.nav.closeWindow(“Report PDF”)[/code]

Thanks Travis,

But what happened to my delay (invokelater)? Do I need to a delay for the report viewer to open before printing?

Thanks.

Yes you can put that back in. Just make sure it is inside of your print function.