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.

DarkBASIC Discussion / Time-Measurement

Author
Message
Holden
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location:
Posted: 17th Dec 2002 03:14
Hi, once again it's me with another novice-problem.
At that point I'm reading through the commands-listings and what sounds interesting I try to use for some sample programs. What I want to do now is to measure the time I press a button. I have a sphere with the possibility, to rotate along the Y-Axis (left, right). Now I want to come up with the time, I pressed either the left- or right-direction key. The way I tried it is to use the timer, get it on the beginning and the and and substract the first from the second value. Is that possible? I encounter the problem, that I cannot "freeze" the starting and and time to perform my calculation. However, I'm totally new to programming and therefore I hope you don't blame me for that piece of code. /g

START = TIMER()
WHILE Leftkey()=1
SET CURSOR 5, 150
PRINT START
aY# = WRAPVALUE(aY#+5)
SET CURSOR 15,550
PRINT TIMER()
YRotate Object 1,aY#
SYNC
ENDWHILE
ENDST = TIMER()
PRINT ENDST, " - ", START, " = "
TIME=ENDST-START
PRINT TIME
ironhoof
21
Years of Service
User Offline
Joined: 3rd Sep 2002
Location:
Posted: 17th Dec 2002 09:45
Make it wait till timer()=0 the timer loops once it reaches a scertain level i believe um i think that shouldnt take long unless the tier is a 32 bit number..

-----\
There was a man on the stairs that wasn't there.
He wasn't there agian today I think he's from the CIA.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 18th Dec 2002 00:24
You could combine the lines:

ENDST = TIMER()
PRINT ENDST, " - ", START, " = "
TIME=ENDST-START
PRINT TIME

to:
TIME = TIMER()-START
PRINT TIME+START, " - ", START, " = ", TIME

That's more precise.

BTW: The timer() function returns an Integer (32Bit, signed)

Ogres have layers.
AceDad
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: - Please Select -
Posted: 20th Dec 2002 02:08
Also

Don't Write your code like that!!!

This is a very important Warning!

Your code should be clean and easy to look at!

you need to include lots more (rem or `) in it to explain

what everything is doing! No matter how mundain! Yes your

program is simple but you must learn these habbits early so

when you write a much larger program you will be able to

read it and make adaptations Thats my 2 cents!

Login to post a reply

Server time is: 2024-03-03 16:52:40
Your offset time is: 2024-03-03 16:52:40