Script runs multiple times on one trigger

I have a script triggered by a property change event on a calendar object. When I select a date on the calendar the script will run multiple times, with different results. I am using this to set up a database selection in another object and need to ensure the script only runs one time to set up the parameters.

I have also tried attaching the script to the mouse click event but that did not seem to run at all.

Here is the script I am running:

[code]from java.util import Calendar
cal = Calendar.getInstance()
cal.add(Calendar.HOUR, -24)
olddate = cal.getTime()

calen = event.source.parent.getComponent(“Calendar”)
date =
if date < olddate:
print “Archive”
event.source.parent.getComponent(‘PassData’).Database = ‘L_PROC_DATA’
event.source.parent.getComponent(‘PassData’).TableName = ‘COIL_PROC_SUMMARY’
print “Active”
event.source.parent.getComponent(‘PassData’).Database = ‘Tmill’
event.source.parent.getComponent(‘PassData’).TableName = ‘RTM_COIL_HSIO_SUM’[/code]

Any help would be greatly appreciated.

Pat Russell

Um, I think you want to filter the property change.


if event.propertyName == “”:

You are correct.

Added this line to the beginning of the script:

if event.propertyName == "Date":

I did manage to get it filtered so that the script only runs once but still have a problem with the if statement not evaluating properly.

Is there a better way to evaluate the time difference between two dates?


Dates aren’t directly comparable using the less-than operator ("<"). Try using their time attribute, which is an 8-byte integer representing the time in UTC as milliseconds since Jan 1 1970 - it should provide reliable comparison.


if date1.time < date2.time:

Thanks for the reply.

I worked with Michael from tech support late yesterday afternoon and we used the following solution:

[quote] olddate = system.db.dateFormat(olddate,“yyyyMMdd”)
date = system.db.dateFormat(date,“yyyyMMdd”)
dateDiff = int(date) - int(olddate)
if dateDiff < 0:

It works like a charm!