Computer Science Canada

Need Help coding a Clock program = Gmail Invite.

Author:  linecode [ Thu Jun 17, 2004 3:18 pm ]
Post subject:  Need Help coding a Clock program = Gmail Invite.

I have 2 Gmail invites, anyone interested in doing a program for me. I will give you a link to the turing software that is used in windows, as well as a document explaining the instructions to what the clock needs to look like and what it suppose to do? In return I will give u a Gmail invite to have 1 gig of email service from Google. Upon completion and the program being able to work, I will send you the invite.

Anyone interested PM. or post back..i will be checking it every so oftan. It is really important for me.

Thank you all in advance.

Author:  Delos [ Thu Jun 17, 2004 4:40 pm ]
Post subject: 

What category does this fall under?

Contractual Breech?

Hehehe...the fun ticks on...

Author:  linecode [ Thu Jun 17, 2004 4:43 pm ]
Post subject: 

I suck at coding. And i need help...and for the help my thank you would be by giving a invitation to a gmail account. its a nice gesture to thank the person for their help.

all i ask is for help.

Author:  DanShadow [ Thu Jun 17, 2004 6:09 pm ]
Post subject: 

Ya see, there is no forum in the index for what your asking for. This is Turing Help, not "please do my damn project because im a lazy freak" forum. I decided to make the clock program decoding your computers clock, I even added an alarm feature. Now im just gonna sit an look at the program and think about you. And no, im not posting it, now go do your own work, if you have a question, ask, and we will help. Geez, if I was the Turing Mod, I would delete this.

Author:  linecode [ Thu Jun 17, 2004 6:16 pm ]
Post subject: 

wow. if i knew how to code in turing i would do it. but i dont. why is everyone such an asshole so far that has posted?

i tried doing it...and im lost in doing it. why cant someone help which i will show my gratitude back.

im sorry if i have offended people with my request. but i am just asking for help.

Author:  Mazer [ Thu Jun 17, 2004 6:23 pm ]
Post subject: 

linecode wrote:
all i ask is for help.

No you didn't. Seriously, if you ask for help chances are we will help you. Come with a specific problem, and we can give you a hint or solution. Don't be stupid man, this really pisses us off.

Author:  linecode [ Thu Jun 17, 2004 6:34 pm ]
Post subject: 

i need to make a command to the clock program that will have a put statement asking the user to input the starting time and the clock will set itself to that time and the next question the user will be asked whether in real time or in fast mode for the time to go in.

I figured out that i will need to set real time to 1000 and fast to 500 (or less) to go really quickly.

what code do i use so that the instructions the users commands for the clock to do?

Author:  Dan [ Thu Jun 17, 2004 7:08 pm ]
Post subject: 

Here is the basick idea of how to do real time:


var offset : int

put "in put start time in secs: "
get offset

var startTime : int := Time.Sec

    put (Time.Sec - startTime) + offset
end loop

to input time in a noraml format you can use the Time.DateSec to covert a string to a number in secs.

for fast time you could do the same thing but with a couter and a nomral dealy.

NOTE: in new verson of turing there is a Time.dealy method witch is an easer way to real time dealys then keeping track of the start time.

Author:  AsianSensation [ Thu Jun 17, 2004 7:14 pm ]
Post subject: 

wait, do you want to reset the system clock, or are you just interested in keeping track of time in your own program?

it's rather hard to reset system clock with turing, but easier if you want to keep track of your own time. Use the time function, something like this:

var second, t1, t2, choice : int := 0
put "How many seconds?"
get second
put "What mode?"
get choice

t1 := Time.Elapsed
    t2 := Time.Elapsed
    if choice = 1 then
        if t2 - t1 >= 1000 then
            t2 := 0
            t1 := Time.Elapsed
            second += 1
        end if
        if t2 - t1 >= 500 then
            t2 := 0
            t1 := Time.Elapsed
            second += 1
        end if
    end if
    put second
end loop

this asks the user to input how many seconds, and then it checks to see the time passed, and adds to your seconds variable every second or half second, depend what mode you chose.

Author:  linecode [ Thu Jun 17, 2004 7:22 pm ]
Post subject: 

no need for a restart. just asked in the beginning...what time do you want to start the clock at? and then be real time or fast time? thats the main idea.

thank you for the help. i appreciate it extremely. as i havent gotten a warm welcome from some of the members due to the way I asked for help. but i was just being honest. I know the basics of turing, i am not advanced, i am a economics student...not a programmer.

I thank you for your help. and thank in advance for the further help I will recieve. Thank YOU! Very Happy

Author:  Delos [ Thu Jun 17, 2004 8:04 pm ]
Post subject: 


time ( var t : string )

Description The time statement is used to determine the current time of day. Variable t is assigned a string in the format "hh:mm:ss". For example, if the time is two minutes and 47 seconds after nine A.M., t will be set to "09:02:47". Twenty-four hour time is used. For example, eleven thirty P.M. gives the string "23:30:00".

Example This program greets you and tells you the time of day.

var timeOfDay : string
time ( timeOfDay )
put "Greetings!! The time is ", timeOfDay

Details Be warned that on some computers such as IBM PC compatibles or Apple Macintoshes, the time may not be set correctly in the operating system. In this case, the time procedure will give incorrect results.

I'm guessing that you don't have the helpfile on your version of Turing...we have the same type at school (no, I'm not being sarcastic...)'s been a while since someone called me an @$$0...let's see...about a week now! Very Happy.

NEhow, just edit the above code a bit and

var timeOfDay : string
    time (timeOfDay)
    locate (1, 1)
    put "Greetings!!  The time is ", timeOfDay
    exit when hasch
    % as soon as you press a key it exits.
end loop

Now that you've seen 3 or so examples of how to use the various time functions, see how much farther you can get w/ your proj...

Hehehe...I'm an @$$...hahahahahhahaa....

Author:  linecode [ Thu Jun 17, 2004 8:24 pm ]
Post subject: 

thats awesome, that gives me a great help what to do. thank you!

Author:  templest [ Fri Jun 18, 2004 9:42 pm ]
Post subject: 

You made a compsci account just to bribe us with a gMail account... you bastard. Evil or Very Mad

How about you just be nice and give me one? Very Happy

Author:  Dan [ Fri Jun 18, 2004 10:02 pm ]
Post subject: 

i have a fealing he dose not realy have any invites....

if he did u whould think he whould at least have his e-mail in his profile as @gmail Rolling Eyes

Author:  templest [ Sat Jun 19, 2004 12:20 am ]
Post subject: 

good point, if I was him I'd only have 1 invite to give away. Laughing

Author:  AsianSensation [ Sat Jun 19, 2004 3:28 pm ]
Post subject: 

meh, doesn't really matter to me if he has the invite or not, we are not a reward-based programming/help community. But if he actually doesn't have the invites, it will only make himself look bad, because we would have helped him regardless. I think alot of members were cold to him in the beginning is because we got way too many of those "do my Final Project and I'll paypal you $10" type of messages.

Author:  linecode [ Tue Jun 22, 2004 9:15 pm ]
Post subject: 

lol. interesting posts. i do have an gmail acct. i didnt not want to or was it my intention to bs anyone.

Author:  linecode [ Tue Jun 22, 2004 9:19 pm ]
Post subject: 

Okay, lets do it this way...I have been getting help from my friend for the past 2 weeks trying to get this program done for the clock to work.

But i need the two or three commands as many have helped me already (thank you) have the user input the time they want to start out with and whether to have it be going in real time or is fast pace mode. Check the attachment.

Whoever wants to complete the rest of the code for this program I will be HAPPY to give out my GMAIL invites to those who helped me. I have ONE left. And if i will get more from gmail...i will surely come back and invite those who have helped me. make sure u post anything but hotmail or yahoo...they block gmail invites.

I will prove to you all my honesty.

here is the code...


procedure displayClock (varhour, varminute, rate : int)

    var hourHand, minuteHand, secondHand : int
    hourHand := 70
    minuteHand := 80
    secondHand := 100

    setscreen ("offscreenonly")
    const PI := 3.14159
    var second, minute, hour : int
    var x, y, x2, y2 : int
    var ang : real
    second := 0
    minute := varminute
    hour := varhour

    var chars : array char of boolean   
        delay (rate)
        second := second + 1
        if second = 60 then
            second := 0
            minute := minute + 1
            end if
        if minute = 60 then
            minute := 0
            hour := hour + 1
            end if
        if hour = 12 then
            hour := 0
            end if
        %hour hand
        ang := ((hour + (minute / 60)) / 12) * 360 - 90
        x := round (cos (-ang * (PI / 180)) * hourHand + maxx div 2)
        y := round (sin (-ang * (PI / 180)) * hourHand + maxy div 2)
        drawline (maxx div 2, maxy div 2, x, y, 7)
        %minute hand
        ang := (minute / 60) * 360 - 90
        x := round (cos (-ang * (PI / 180)) * minuteHand + maxx div 2)
        y := round (sin (-ang * (PI / 180)) * minuteHand + maxy div 2)
        drawline (maxx div 2, maxy div 2, x, y, 7)
        %second hand
        ang := (second / 60) * 360 - 90
        x := round (cos (-ang * (PI / 180)) * secondHand + maxx div 2)
        y := round (sin (-ang * (PI / 180)) * secondHand + maxy div 2)
        drawline (maxx div 2, maxy div 2, x, y, 4)
        %draw face
        for i : -90 .. 270 by 6
            if i mod 15 = 0 then
                x := round (cos (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand))) + maxx div 2)
                y := round (sin (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand))) + maxy div 2)
                x2 := round (cos (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand)) + 10) + maxx div 2)
                y2 := round (sin (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand)) + 10) + maxy div 2)
                x := round (cos (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand)) + 5) + maxx div 2)
                y := round (sin (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand)) + 5) + maxy div 2)
                x2 := round (cos (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand)) + 10) + maxx div 2)
                y2 := round (sin (-i * (PI / 180)) * (max (hourHand, max (minuteHand, secondHand)) + 10) + maxy div 2)
            end if
            drawline (x, y, x2, y2, 7)
        end for
        drawoval (maxx div 2, maxy div 2, max (hourHand, max (minuteHand, secondHand)) + 10, max (hourHand, max (minuteHand, secondHand)) + 10, 1)
        Input.KeyDown (chars)
    end loop
end displayClock

displayClock (1, 30, 1000)

I will stay on. Please dont take this post the wrong way. I thank everyone in Advance for their help. As i mentioned before, I am not a programmer.

Author:  Dan [ Tue Jun 22, 2004 10:23 pm ]
Post subject: 

linecode wrote:
make sure u post anything but hotmail or yahoo...they block gmail invites.

thats is aucctlay not true, i have given invites to many poleop who use hotmail and at worse yahoo just puts them in the spam foldoer.

Author:  linecode [ Wed Jun 23, 2004 9:13 am ]
Post subject: 

some do some don't. everyone has different experiences with the invites. but yahoo, yeah they put anything in the junk mail folder.

no one wants to take a stab at completing the two or three commands?

Author:  AsianSensation [ Wed Jun 23, 2004 4:15 pm ]
Post subject: 

seems simple enough:

var tmp : string

put "What's the starting time, in the form of hh:mm"
get tmp

displayClock (strint (tmp (1 .. 2)), strint (tmp (4 .. 5)), 1000)

but they must input in the form of hh:mm, like 03:10. I didn't bother to error trap, so if the input isn't like that, you get a run time error. So you could either ask for the hour and minute separately, I was lazy, so I did it like this.

Author:  the_short1 [ Wed Jun 23, 2004 7:08 pm ]
Post subject: 



dont use:

delay (number here)
in ur program or it will be extremely inacurate..

Time.Delay (time here) < is acually acurate..

Author:  zylum [ Wed Jun 23, 2004 10:07 pm ]
Post subject: 

you're wrong, if you try :


delay (10000)
put Time.Elapsed



Time.Delay (10000)
put Time.Elapsed

it shows the exact same thing, well maybe a millisecond or 2 off, but on average its the same thing

Author:  AsianSensation [ Thu Jun 24, 2004 8:54 am ]
Post subject: 

alright, to clear up confusions about people doubting linecode (we were pretty harsh in the beginning), linecode did have a gmail invite, I got it, but since I already have a gmail account, I guess I don't need it anymore, so I think I'll donate it to, and we can give out the invite for the FP contest or something. (Though I'm still pissed that AsianSensation@gmail, and AznSensation@gmail were both taken.....)

Author:  the_short1 [ Thu Jun 24, 2004 9:28 am ]
Post subject: 

well u prob have an average copmputer...

hacker dans laptop would be done 5 seconds before the time.delay one

and mine... (peice of crap) would prob take ten seconds longer then the time.delay one..

i had that problem with speeds in my pacman game.. that is why i turned to time.delay...

but w/e

ok... i tried reading ur code.... but either im really tired rite now... or i just dont understand all it....

yea ... asian sensation...!! that must suck having those taken,.. Sad but donate to FP ... thats a GREAT idea!

Author:  zylum [ Thu Jun 24, 2004 11:35 am ]
Post subject: 

that's nonsense. delay and Time.Delay are the same thing except that Time.Delay is in the predefined unit "Time". they are the same procedure and it makes no difference which you use.... in fact make your own delay procedure if you're so skeptical:

proc DELAY (t : int)
    var startTime := Time.Elapsed
        exit when Time.Elapsed - startTime >= t
    end loop

DELAY (10000)
put Time.Elapsed

it's never off by more than 2 milliseconds for me... using my code, the most it could be off by is the amount of time your computer takes to compute one loop which is nothing, or about 2 milliseconds for my machine.

Author:  Paul [ Thu Jun 24, 2004 3:48 pm ]
Post subject: 

not like it makes a large difference but:
Time.Delay (10000)
put Time.Elapsed
I got

and with

delay (10000)
put Time.Elapsed
I got

Author:  this_guy [ Thu Jun 24, 2004 5:29 pm ]
Post subject: 

i got 10004 for both of them.
mine must be really slow, or i should close some of my internet explorer windows.

Author:  the_short1 [ Thu Jun 24, 2004 6:03 pm ]
Post subject: 

zylum.... thats a nice way to make a delay.....

well.... like i was in my case... . cuz u are doing that on an EMPTY turing program..

try doign the same test while in full fledged game is going.... then its WAY off cuz ur PC speed dips a lot more and then the delay(time) one is much slower or faster...

thats my experience..

ur system is idle when just doing that.... when doing my game ur pc is using more and prob does that delay a lot longer..... at least for me...

heres the results for that test on my pc..

Time.Delay (10000)
put Time.Elapsed

i got 10190



delay (10000)
put Time.Elapsed

i got 10016

now... is that not a HUGE difference...
get dan to do the same test with his alienware pabtop.... it will be more liokle 900 for one... and like 1000 for the other..

wait a second.... . that was odd...time.delay shoulda be the one with 10016... . wait i know why.... my PC clock is SLOW.... my batery is dying.. whenever i shutdown... the comp stops recording time... meh... im too lazy to get a new batery...

either way.... depends on ur PC..... sometimes it really makes a difference...

Author:  zylum [ Thu Jun 24, 2004 6:21 pm ]
Post subject: 

it will never be less that the number you specify.... anyways, my delay seems to be the most accurate in any case, no matter the conditions.

Author:  Dan [ Thu Jun 24, 2004 6:58 pm ]
Post subject: 

I tested them and i got the same for values for both, i even tryed diffrent lengths for the dealys and got the same.

Author:  the_short1 [ Thu Jun 24, 2004 7:06 pm ]
Post subject: 

i guess it only effects the really slow comps like mine.,..


i take back some of my argument..

Author:  cbc [ Wed Jul 07, 2004 8:09 pm ]
Post subject: 

shudnt Time.Delay and delay be the same thing?

its just like locate and Text.Locate

colour and Font.Colour

Author:  Delos [ Wed Jul 07, 2004 8:16 pm ]
Post subject: 

Theoretically yes. But in practise, one finds that delay() is less reliable for cross-platform compatibility than Time.Delay() is.

In other words...a
delay (500)
is less likely to give you that desired half second pause than a
Time.Delay (500)
on a variety of computers.

This is due to the fact that Turing works its processor around the CPU speed...yeah...that thing...
Thus being...delay()s can really screw up, especially in programmes in which graphics/audio must sync...

Author:  Mazer [ Wed Jul 07, 2004 8:52 pm ]
Post subject: 

Ya sure about that? AFAIK, delay() is the same function as Time.Delay() that HoltSoft has available for those that don't want to type as much. Just like drawfillbox() vs Draw.FillBox().

Author:  Delos [ Wed Jul 07, 2004 9:16 pm ]
Post subject: 

I'm not entirely positive about it...I do know that the whole Draw./Time. thing came into play after Holt moved to OOT...the older commands being intrinsic in Classic, to allow for some backward compatibility, the left them in.

I think (note the uncertainty) that I tried this out once, using delay() vs. Time.Delay() w/ the above described combination of graphics and would seem that the latter form of the command must have caught my attention...otherwise, I mightn't have said what I did...but I could be wrong.
It was a while ago...if ever... Confused .
Clarification anyone?

Author:  the_short1 [ Wed Jul 07, 2004 9:56 pm ]
Post subject: 

u sound right delos..

cuz i based my argument on a full program .. meaning.. basically my pacman game with sounds and graphics.... and it played a HUGE role which one i used...

i used Time.Delay for acuracy..
delay () when i was being lazy and it did not matter..

Author:  this_guy [ Thu Jul 08, 2004 5:54 pm ]
Post subject: 


i've always thought they were the same thing, just a different way of calling the same procedure, but i've always prefered writing the non-lazy way

Author:  the_short1 [ Thu Jul 08, 2004 7:03 pm ]
Post subject: 

the non-lazy way of life.... why? thats so much extra work Razz Wink

all that shift holding... and extra letters...



Author:  TheZsterBunny [ Sat Aug 07, 2004 8:32 am ]
Post subject: 

Yeah, i know this is an old post, but I couldn't resist.


var tod, tup, tap : string
var sc, mn, hr : int
var counter : int := 0
var asec, amin, ahr : real
var fonta : int := Font.New ("Arial:8")
setscreen ("offscreenonly,nobuttonbar,title: Clock Display")
time (tup)
tap := tup

    time (tod)
    if tap not= tod then
        time (tup)
        tap := tup
        hr := strint (tup (1 .. index (tup, ":") - 1))
        tup := tup (index (tup, ":") + 1 .. *)
        mn := strint (tup (1 .. index (tup, ":") - 1))
        tup := tup (index (tup, ":") + 1 .. *)
        sc := strint (tup)
        asec := (sc / 60) * (Math.PI * 2)
        amin := (mn / 60) * (Math.PI * 2)
        ahr := (hr / 12) * (Math.PI * 2)
        drawoval (maxx div 2, maxy div 2, 42, 42, blue)
        drawoval (maxx div 2, maxy div 2, 58, 58, blue)
        drawoval (maxx div 2, maxy div 2, 62, 62, green)
        drawoval (maxx div 2, maxy div 2, 78, 78, green)
        drawoval (maxx div 2, maxy div 2, 82, 82, red)
        drawoval (maxx div 2, maxy div 2, 98, 98, red)
        Draw.ThickLine (round (sin (ahr) * 55) + maxx div 2, round (cos (ahr) * 55) + maxy div 2, round (sin (ahr) * 45) + maxx div 2, round (cos (ahr) * 45) + maxy div 2, 1, blue)
        Draw.ThickLine (round (sin (amin) * 65) + maxx div 2, round (cos (amin) * 65) + maxy div 2, round (sin (amin) * 75) + maxx div 2, round (cos (amin) * 75) + maxy div 2, 1, green)
        Draw.ThickLine (round (sin (asec) * 95) + maxx div 2, round (cos (asec) * 95) + maxy div 2, round (sin (asec) * 85) + maxx div 2, round (cos (asec) * 85) + maxy div 2, 1, red)
        drawline (maxx div 2 - 1, maxy div 2 + 100, maxx div 2 - 1, maxy div 2 + 110, black)
        drawline (maxx div 2 + 1, maxy div 2 + 100, maxx div 2 + 1, maxy div 2 + 110, black)
        drawline (maxx div 2 + 100, maxy div 2, maxx div 2 + 110, maxy div 2, black)
        drawline (maxx div 2 - 100, maxy div 2, maxx div 2 - 110, maxy div 2, black)
        drawline (maxx div 2, maxy div 2 - 100, maxx div 2, maxy div 2 - 110, black)
        drawoval (maxx div 2, maxy div 2, 112, 112, black)
        Font.Draw (tap, maxx div 2 - (Font.Width (tap, fonta) div 2), maxy div 2 - 4, fonta, black)
        % counter += 1
        % locate (1, 1)
        % put counter
    end if
end loop

okay, the outermost circle (black) is the cardinal points on the clock
the next circle inwards (red) is the seconds
next (green) minutes
next (blue) hours
and finally, in the centre we have the time for all those who are too lazy to figure it out.


Author:  DanShadow [ Sat Aug 07, 2004 2:28 pm ]
Post subject: 

But...did you read the first part of the post? It was a guy asking us to give him code for a project (or something like that). So you technically just broke our non-cheating rule, even if it is an old post. Please refrain from providing people with complete answers, especially if thats what they are asking for. Like, if somebody asks a question, its better to answer a question, then to provide them with every bit of information they eliminates the learning experience. Anyway...just thought Id add that in. Razz