Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Can't understand this:

Author
Message
PST
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 9th Apr 2004 17:41
What's the diference between wait and sleep.
Does timer start with the program?

I will probably have more questions later but these are messing with me... can some one help please?
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 9th Apr 2004 18:21
wait and sleep pretty much do the same thing - halt execution of your program for a specified amount of time.

Timer() is a function that returns the number milliseconds since midnight (or some preset starting point) You can use timer calls to compare/test the amount of time that has passed between the calls and use it to trigger certain things in your program, without halting execution.

each of these has it's place in programming in dbp


Home of the VB.NET Class Builder Utility - Demo and FULL versions now available!!
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 9th Apr 2004 20:10
wait and sleep effectivley do the same thing, but from the standpoint of the computer WAIT will be eating cpu time counting down and repeatedly checking when it is time to continue, while SLEEP effectivley sets an alarm and lets the computer have cpu time back for other stuff until the program has to continue again, that is what is supposed to happen (and does in other languages or dialects of basic even), but I suspect that sleep and wait do exactly the same thing in DB (ie busy waiting), although I havent tried this to see if this is the case.
Timer() is a system thing that tells you how many milliseconds it was since the system started up, it`s the lowest level of the system that is used by things like the system clock, hardrives and DB to work out the passage of time since power on (the system clock is nowdays a battery backup thing and somewhat seperated from the system clock...in the old days you had to enter the correct time when you started your pc, it actualy stopped the bootup and asked for the time, and then used timer to keep track of the current time by adding the time onto timer()), timer is just best considered as an ever increasing number that tics once per 1000th of a second that you can use to check time in your programs when you are more interested in milliseconds than hours minutes and seconds
cheers.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
PST
20
Years of Service
User Offline
Joined: 15th Mar 2004
Location:
Posted: 9th Apr 2004 22:23
Ok... not very interesting commands...
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 10th Apr 2004 01:41
Without timer(), you can't have frame rate independent movement. Interesting and important are not dependent on each other.
--
TAZ

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 10th Apr 2004 03:02
Yes, I can confirm that WAIT and SLEEP are identical for DBPro. Whether they are different in DBC I don't know, but I would suspect not.

*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++ http://www.matrix1.demon.co.uk
Xander
21
Years of Service
User Offline
Joined: 3rd Mar 2003
Location: In college...yeah!
Posted: 10th Apr 2004 23:26
Using timer() is very very important for many things, including what Zircher said (constant speed with variable frame rates), preventing continuing button pressing, sensing double clicking, etc...

Xander Moser of Bolt Software
Firewall: Your Computer's First Defense - Real Time Strategy game
[href][/href]
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 11th Apr 2004 01:51



Home of the VB.NET Class Builder Utility - Demo and FULL versions now available!!

Login to post a reply

Server time is: 2024-09-22 04:22:31
Your offset time is: 2024-09-22 04:22:31