PowerBuilder Tips
Why won't my timer work?
A quick intro
A timer is a good way to create a regular and frequent events. Or just to let the program sleep for a bit and then come back. But sometimes the timer doesn't work. But it's always easy to fix.
You can add a timer to any window. But it must be a window. That is a Windows restriction and not a PowerBuilder issue. For example, I have a window in which I wish to check something every 15 seconds. In the open even to this window, I have:
timer(15)
Then I put the code for the checking in the timer event of that window.
What didn't work and how I fixed it
A few days ago, I added a timer event to my frame window. It ran fine under testing in the development environment, but once I created an exe, the timer didn't work. I couldn't figure it out. So I went to dejanews and found what I needed. It turned out that I should have been reading the manual.
I added an extra [optional] parameter to my timer call. It became:
timer(15, this)
I recompiled, and it worked. For some reason, under certain circumstances, the timer gets confused and doesn't get triggered properly. My rule-of-thumb is 'always specify the window for the timer'.
[ About | Services | Products | Search | Feedback | Support ]
This page last updated: Wednesday, 23 February 2000 |