I have a standalone RT where I'd like a script to check the license validity at a timed interval, independent of the window that is open. Is there a neater way of doing this than having an 'Install OnTimer Script' for each window?
To answer the specific question,
Perhaps you could open a small window on startup located at a position such as top = -500 so that it is not visible to the user and then you set up the Timer from Install OnTimerScript in that window before returning control to the main window.
I would think that having the script running in the main window would be enough. Is this a case where the user closes the main window when a new window opens?
Why do you need to verify the license so frequently?
So curious questions aside, think about this:
When the file opens have it verify the license and create a Global variable with a time stamp that the license verified.
On the main user layout and possibly the layout(s) used most frequently add an OnLayoutload script trigger that checks the global variable.
In the script, using the timedelay you want, add it to If the value if the Global variable, and if the current timestamp is > then the check time verify the license and update the Global variable. If the current time stamp is less, exit the script.
This eliminates the OnTimer script but should keep your RT time in compliance with your license. I think. It also eliminates issues if the user has multiple windows open and multiple checks showing up.
I've tried out the Phil's approach, mostly because it seemed simpler. In most respects I've got it to work as desired, but the Install OnTimer Script has a problem:
If [ Home::Lic_ID = Home::License_ID and Home::Lic_n > 0 ]
Exit Script [ ]
Show Custom Dialog [ Title: "Buy a License"; Message: "License invalid"; Default Button: “OK”, Commit: “Yes” ]
Perform Script [ “Close” ]
The above works fine on it's own, but always signals the License as Invalid when run through the 'OnTimer'. I have also tried the above opposite way around in the 'If' step, ie. not = and < 0.
What am I missing?
You haven't explained how you manage the values in those fields.
I'd check to things:
if those fields are not global, make sure the correct record is current.
Also make sure that the window's current layout is the correct layout.
No the values weren't global, there's only 1 record but the values need to update, so it precludes global. I've done as suggested, going to the appropriate layout > commit/refresh > back to original layout > works well.
I'll do more checking to be sure, but the advice is much appreciated.
"...but the values need to update, so it precludes global. "
Don't see why that "precludes global", but I think "refresh" is the crux of the matter. How do these values update? From user input in the other window?
You may just need to commit records to get the results you need, provided that the timer window is on the right layout when it evaluates.
Sent from my iPhone
Global vs calc: When I clicked global the option to have the calc update disappeared and it needs to for the RT to work as planned.
I've 'committed and refreshed', just to be sure. And, a similar problem with an object not appearing/disappearing on 1 layout in relation to the field setting on another was cured by setting the field to global. So you've solved 2 problems with you suggestions on 1! Thank you.
Retrieving data ...