|Title:||Using nonvisual timers on other objects than windows (PB5 32bit only)|
|Download:||( timer.zip ):|
In PB6 you have the timing object. In PB5 you don't. You only have a timer event on windows. However, there are two windows API functions which provide you timing functionality: SetTimer() and KillTimer(). These functions work perfectly well but they need a visual object to send the WM_TIMER event to. This WM_TIMER event has to be mapped to an userevent on the visual userobject via pbm_timer. This all works perfectly well. You can have many timers at the same time (256 max). But, you actually want to have the timer functionality available in a NonVisual Userobject. Here's a trick to do that because there is one nonvisual object in PowerBuilder that actually is visible, but not shown, and is able to be created with the CREATE statement: the datastore. So, I created a new standard nonvisual userobject of type datastore and used it for the SetTimer() and KillTimer(). The result is that we can create a timer event on a nonvisual userobject, which we than can use for many purposes. Check out the attached PBL. It contains a sample (PB5, 32bit) how 8 timers together can work on one window.
Secondly, with PB5, you can only have timers with a delay of max. 65 seconds. With these function calls, I don't know what the limit is but I succeeded in setting a timer of 3 minutes. The argument of the interval is an unsignedlong of milliseconds so that's about 4 billion milliseconds ( quite a while, who's willing to verify? )
Have fun with it.
PS. This source won't work with PB6 ( dunno why...who does? )