Page 1 of 1
Posted: Sat Jul 13, 2002 2:54 am
by BackupUser
Restored from previous forum. Originally posted by stede.
Anyone know of any timer functions in PureBasic. Hopefully with sample code.
Stede
Posted: Sat Jul 13, 2002 4:33 am
by BackupUser
Restored from previous forum. Originally posted by Danilo.
There was a topic about this 4 days ago.
Please read the forum (there is a |Search| button on top):
Code: Select all
[b]"Timer" Commands?[/b]
[url]http://forums.purebasic.com/english/viewtopic.php?t=1599[/url]
cya,
...Danilo
(registered PureBasic user)
Posted: Sat Jul 13, 2002 5:10 am
by BackupUser
Restored from previous forum. Originally posted by stede.
I just read that topic and it is great but not what I am looking for...
I need to get the time in a variable then every loop check this variable against the current time and if it is greater then a set amount then exit the loop.
For example:
t = Now()
while true
if datediff("s",t,now()) then exit while
blah, blah
end while
Thanks again!
Stede Troisi
There was a topic about this 4 days ago.
Please read the forum (there is a |Search| button on top):
Code: Select all
[b]"Timer" Commands?[/b]
[url]http://forums.purebasic.com/english/viewtopic.php?t=1599[/url]
cya,
...Danilo
(registered PureBasic user)
Posted: Sat Jul 13, 2002 10:24 am
by BackupUser
Restored from previous forum. Originally posted by fweil.
Hello,
Depending on the time range you have to check ...
;============
t = GetTickCount_()
delay = 0
limit = WhatUWant
Repeat
...
delay = GetTickCount_() - t
Until delay > limit
;============
But the issue can be then that GetTickCount_() has a low limit (1 day). So you can collect day and time information to accumulate a range of many days, months or years.
For date and time stuff, you can use the TimeandDate lib available from El_Choni I believe.
Rgrds
Francois Weil
14, rue Douer
F64100 Bayonne
Posted: Sat Jul 13, 2002 11:01 am
by BackupUser
Restored from previous forum. Originally posted by PB.
> the issue can be then that GetTickCount_() has a low limit (1 day).
Do you mean 1 day if used as in your example? Because GetTickCount() has a life
span of 49.7 days before it actually wraps back to 0...
PB - Registered PureBasic Coder
Posted: Sat Jul 13, 2002 1:37 pm
by BackupUser
Restored from previous forum. Originally posted by fweil.
You are right PB ... I missed the good value. GetTickCount_() returns a long integer so it is the max value / 86400000 (millisecs per day) ...
Sorry for this mistake.
Francois Weil
14, rue Douer
F64100 Bayonne
Posted: Sat Jul 13, 2002 4:30 pm
by BackupUser
Restored from previous forum. Originally posted by stede.
Awesome! What is a tick??? Is it a millisecond? Also why isn't this procedure documented?
Stede
Hello,
Depending on the time range you have to check ...
;============
t = GetTickCount_()
delay = 0
limit = WhatUWant
Repeat
...
delay = GetTickCount_() - t
Until delay > limit
;============
But the issue can be then that GetTickCount_() has a low limit (1 day). So you can collect day and time information to accumulate a range of many days, months or years.
For date and time stuff, you can use the TimeandDate lib available from El_Choni I believe.
Rgrds
Francois Weil
14, rue Douer
F64100 Bayonne
Posted: Sat Jul 13, 2002 4:51 pm
by BackupUser
Restored from previous forum. Originally posted by Paul.
To all the new people on the forum...
If you see commands that contain an underscore after them like GetTickCount_() or GetDC_() or SetWindowText_() you are no longer using native PB commands, you are using Windows API commands.
Original documentation on Windows API commands and be found at msdn.microsoft.com
(of course there are many other sites that try and expain various API commands a little easier for the newbie)
If you were to look at the API documentation for a command like GetTickCount_() you would get:
Code: Select all
The GetTickCount function retrieves the number of milliseconds
that have elapsed since Windows was started.
DWORD GetTickCount(VOID)
Parameters
This function has no parameters.
Return Values
If the function succeeds, the return value is the number of
milliseconds that have elapsed since Windows was started.
Remarks
The elapsed time is stored as a DWORD value. Therefore, the
time will wrap around to zero if Windows is run continuously
for 49.7 days.
Windows NT: To obtain the time elapsed since the computer was
started, look up the System Up Time counter in the performance
data in the registry key HKEY_PERFORMANCE_DATA. The value
returned is an 8 byte value.
Edited by - paul on 13 July 2002 17:55:52