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.

Geek Culture / C++ time() problem

Author
Message
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 3rd Jan 2004 16:59
@Moderators, especially Rich: Please don't hurt me...

Ok, if nobody gets pissed off, I have a question about the time() function. So, basically, DB's timer makes 1000 counts = 1 sec. while in my book, it says that c++ counts in milliseconds. When I tried it out, I tested it by assigning the current time to a variable, then if the new time is different from the old time, then print it else leave it alone and check again. What happened is that it updates per second, so that means that the timer is counting 1 count = 1 sec. which is not good. Is there something wrong here? I'm using MSVC++6.

People? I hate people. People are stupid.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jan 2004 17:04 Edited at: 3rd Jan 2004 17:09
Got any code we can laugh at... err... look at ?
Anyhoo, your wrong - its updated around every millisecond or so, so the for every second, the timer() command will have increase by 1000


The place for all great plug-ins
flibX0r
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 3rd Jan 2004 17:05 Edited at: 3rd Jan 2004 17:06
Oki, firstly, milli seconds IS 1000ths of a second. Therefore, DBPro counts in milli seconds.

Secondly, how are we to help you with no code, eh?


P.S. They won't kill you cos you put it in the "General" section, so they don't care.


EDIT: Damn. TCA beat me.

Windows has detected a mouse movement... please restart your computer so changes can take effect.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jan 2004 17:11
Quote: "They won't kill you cos you put it in the "General" section, so they don't care"

I care!!! Any things like this I put through the world-famous Instasarcasm Generator®...


The place for all great plug-ins
flibX0r
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Western Australia
Posted: 3rd Jan 2004 17:22
Can i get a copy of that? I only have the demo version

Windows has detected a mouse movement... please restart your computer so changes can take effect.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jan 2004 17:26
Hmmmm.... Let me think about that.....
...hmmm... No...


The place for all great plug-ins
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 3rd Jan 2004 17:35
I left out the code because that mean's I'd have to open my mom's laptop... Yeah, I know DB's timer works that way, but I can't figure out why the the timer I have in C isn't working like DB.

Don't laugh, please. I'm a noob so forgive my inefficient coding, in dos for gods sake.

The exe, just in case. Might have to copy paste.

http://www.freewebs.com/kabouter/dont_laugh.zip

People? I hate people. People are stupid.
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 3rd Jan 2004 17:55
Its just so tempting to crank up the settings, but I better not...
Anyhoo, from MSDN :

Return the time in elapsed seconds. There is no error return.

A call to time or _time64 can fail, however, if the date passed to the function is:

Before midnight, January 1, 1970.
After 19:14:07, January 18, 2038, UTC (using time and time_t).
After 23:59:59, December 31, 3000, UTC (using _time64 and __time64_t).
Remarks
The time function returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC), according to the system clock. The return value is stored in the location given by timer. This parameter may be NULL, in which case the return value is not stored.


The place for all great plug-ins
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jan 2004 17:55
The standard C library time function increments every second. To get better timing than this on machines while still sticking to the standard, you have to play tricks with the select function.

The windows standard library time function (GetTickCount) which DBPro uses increments every 1000th of a second. You simply call it and store the result in a dword.

For higher resolutions than this you would use the Performance timers. For an example of the code needed to use these you can download the source for my utility plug-in and look there.

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 3rd Jan 2004 18:12
@IanM: Don't confuse me further... I've only been doing this for the past week...

Can't someone just modify my code (don't add too much to it, please) to show me how to make it work like DB?

People? I hate people. People are stupid.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jan 2004 18:22
I would, but freewebs won't let me download your code ...

Just use ...

DWORD CurrentTick;
CurrentTick = GetTickCount();

Instead of (I presume) ...

int CurrentTime;
CurrentTime = time(0);

For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 3rd Jan 2004 18:24 Edited at: 3rd Jan 2004 18:32
Hang on. I managed to get it

Here it is ...



For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 3rd Jan 2004 18:38
Hooray!!! Thankies!!!

People? I hate people. People are stupid.

Login to post a reply

Server time is: 2024-11-24 10:54:22
Your offset time is: 2024-11-24 10:54:22