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.

2D All the way! / problems with time

Author
Message
j4cK4zz
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: Norway
Posted: 5th Mar 2003 12:23
yo yo yo... I tried to write a program that takes the time when you press enter.

but it didnt work properly..

i wrote it like this

h=0
m=0
s=0
ms=0
ts=0

do
if return+key()+=1
ts=ts+999
if ts>1000
ms=ms+99
ts=0
cls
if ms>100
s=s+1
ms=0
cls
if s>60
m=m+1
s=0
cls
if m>60
h=h+1
m=0
cls
endif
endif
endif
endif
endif

if inkey$()="r"
ts=0
ms=0
s=0
m=0
h=0
endif

print "press (and hold) ENTER to take the time"
print "press R to reset the timer"

set cursor 320,240 : print "Hours: ",h
set cursor 320,260 : print "Minutes: ",m
set cursor 320,280 : print "Secounds: ",s
set cursor 320,300 : print "MilliSec.: ",ms
set cursor 320,320 : print "NaniSec.: ",ts

sync:loop/code]


I dont know if this is the actually code that I wrote, since I dont have darbasic on this cpu

well mine problem is that I cant get it to take the exact time. Anyone help???

oh yhea.. the program was created with DBPro
j4cK4zz
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: Norway
Posted: 5th Mar 2003 14:14
oops here is the code again

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 5th Mar 2003 16:46
There's a timer() function in DB and DBpro (see help for details).

Example:


Ogres have layers.
Kenan
21
Years of Service
User Offline
Joined: 2nd Mar 2003
Location:
Posted: 6th Mar 2003 00:50
What is the most simple way of using 'time' command in DB?
What is the command for time?

I remember there was a TIMER command in AmigaBasic..back then when I was fooling around with it.. Anything similar in DB=?

empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 6th Mar 2003 01:13
Erm, like I said timer()....

quote from the help files:
This command will get the internal system time, which continually increments at a thousand times a second. The system time is returned in milliseconds, where 1000 units represent 1 second.

Ogres have layers.
Richard Davey
Retired Moderator
21
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 6th Mar 2003 03:23
If you mean the real time (i.e. as in the clock time) then use GET TIME$ and parse the results.

Cheers,

Rich

"Gentlemen, we are about to short-circuit the Universe!"
DB Team / Atari ST / DarkForge / Retro Gaming
j4cK4zz
21
Years of Service
User Offline
Joined: 22nd Dec 2002
Location: Norway
Posted: 6th Mar 2003 12:14
I want the real time... since it is a time taker...
this is just a test that i tried to make since i'm not very good at programing (yet).
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 6th Mar 2003 14:08
Did you try my example?

Rich means the clock time- something like 15:30:12 (format h:m:s). That's just to get the current time.

In order to create something like a stopwatch you need the timer() function.

Ogres have layers.
Xoid
21
Years of Service
User Offline
Joined: 8th Mar 2003
Location:
Posted: 10th Mar 2003 20:43
Hope this helps

sync on : sync rate 0

do
GOSUB GetTime
sync
loop

GetTime:
set text opaque
text 10,10,get time$()
retur
Xoid
21
Years of Service
User Offline
Joined: 8th Mar 2003
Location:
Posted: 10th Mar 2003 20:46
retur = return

LOL

Login to post a reply

Server time is: 2024-04-23 09:01:52
Your offset time is: 2024-04-23 09:01:52