View previous topic :: View next topic |
Author |
Message |
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Jan 15, 2003 6:05 am Post subject: Multiple Timer example... |
|
|
There's been some questions about multiple timers, so
here's one way to do it.
It's not gonna be 100 percent accurate - occasionally
"WAIT EVENT, 1" loses a second for ya, but hopefully ya
won't be using VDS in a missile defense system anyway...
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,Test Program,-1,0,200,40
DIALOG ADD,STATUS,Stat2,@datetime(ss)
DIALOG ADD,STATUS,Stat1,@datetime(ss)
DIALOG SHOW
:EVLOOP
WAIT EVENT, 1
goto @event()
:TIMER
%t = @datetime(ss)
DIALOG SET, Stat1, %t
DIALOG SET, Stat2, %t
rem -- Use GOSUB (not GOTO) if ya want both timers to work --
if @equal(@mod(%t, 2), 0)
GOSUB TIMER1
end
if @equal(@mod(%t, 5), 0)
GOSUB TIMER2
end
goto EVLOOP
:TIMER1
DIALOG SET, Stat1, %t - "2 second timer"
exit
:TIMER2
DIALOG SET, Stat2, %t - "5 second timer"
exit
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Jan 15, 2003 6:26 am Post subject: Re: Multiple Timer example... |
|
|
Mac wrote: | ... but hopefully ya won't be using VDS in a missile defense system anyway... |
Darn! Does that mean that I cannot do that NASA Mars flight control program in VDS ??
I'd better stick with Space Invaders or something instead then...
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Nov 18, 2004 8:29 am Post subject: |
|
|
Thanks for the example.
I need to use two timers in my program.
The first timer runs a code every 300 seconds or 5 minutes, that checks a server for update. And the second timer to be used in a minimize to taskicon thing.
Any chance for a simple example for that? _________________
|
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Nov 18, 2004 10:10 am Post subject: |
|
|
Just use a 1 second time to do a countdown. Do the minimize thing each time. Do the other thing when the countdown reaches 0, and then reset it to 300. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
GeoTrail Valued Contributor
Joined: 18 Feb 2003 Posts: 572 Location: Bergen, Norway
|
Posted: Thu Nov 18, 2004 11:48 am Post subject: |
|
|
Good idea jules.
Thanks _________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|