Computer Science Canada

Timer

Author:  Artimes [ Thu Nov 06, 2003 10:29 pm ]
Post subject:  Timer

This is a simple timer for all of you!

code:


% Timer
% Created by: John Baker
% Created on: November 5th, 2003
% This program is a timer that counts seconds, minutes, and hours

var seconds, minutes, hours : int := 0

    loop

        put "Time " : 5, hours : 2, ":", minutes : 2, ":", seconds : 2

        delay (1000)

        seconds := seconds + 1

        if seconds = 60 then

            seconds := 0

            minutes := minutes + 1

        elsif minutes = 60 then

            minutes := 0

            hours := hours + 1

        end if

        cls

    end loop


Author:  Dan [ Fri Nov 07, 2003 5:19 pm ]
Post subject: 

this whould wrok alot better if you used turings time fuctions. that way it will be real time rather then dependedt on the speed of your computer.

ex.

code:

var startTime:int:=Time.Sec
var endTime:int:= 120 %put time in secondes to run
var curent:int

loop
    curent := Time.Sec  - startTime
   
    exit when curent >= endTime
end loop

Author:  Artimes [ Sat Nov 08, 2003 12:33 am ]
Post subject: 

Kewl, well I was just trying to show my skills some how...


: