Computer Science Canada

countdown

Author:  ecookman [ Mon Dec 08, 2008 6:57 pm ]
Post subject:  countdown

i have tried before on this topic and rdrake gave me some options but were out of my programming skills ( no offense didn't understand)


sooo back to my programming "foundation"


if anyone can help me on making a countdown to Christmas or any day that would be great Very Happy



(sorry mods/admins if you don't like this i ran out of searching material and i wanted to make this a learning experience {and tony thanks but the one you made for me was great but i wanted to make into a .exe and i am not sure how sooo back to what is familiar})

Author:  DanielG [ Mon Dec 08, 2008 7:08 pm ]
Post subject:  RE:countdown

I think the easiest way is to find how many seconds away your date is from 1970, and use Time.Sec to find the time now from 1970, then use mods and divison to rewrite the difference in weeks, days, hours, minutes, seconds, or whatever units you want it to be in.

Author:  rdrake [ Mon Dec 08, 2008 7:48 pm ]
Post subject:  Re: countdown

If you have a choice between VB.NET and Turing, use VB.NET.

C#:
DateTime dt = new DateTime(2008, 12, 25);
TimeSpan ts = dt - DateTime.Now;
Console.WriteLine("There are " + ts.Days + " days left until Christmas.");

Author:  ecookman [ Mon Dec 08, 2008 9:37 pm ]
Post subject:  RE:countdown

i i dunno if it is vb net

just says visual basic express edition so i went to the unforgiving "beast" of turing...


turing codes would be helpful i know nothing about C#... i have looked and ripped some scripts (changing values in variables) but nothing major


p.s thanks for your time

Author:  ecookman [ Mon Dec 08, 2008 9:39 pm ]
Post subject:  Re: RE:countdown

DanielG @ Mon Dec 08, 2008 7:08 pm wrote:
I think the easiest way is to find how many seconds away your date is from 1970, and use Time.Sec to find the time now from 1970, then use mods and divison to rewrite the difference in weeks, days, hours, minutes, seconds, or whatever units you want it to be in.
\


i am sorry you lost me there

to me sounds like i am trying to find Christmas in 1970 and how long it has been since then

Author:  Insectoid [ Mon Dec 08, 2008 9:44 pm ]
Post subject:  RE:countdown

Well, the Turing timer counts in seconds (milliseconds?) from 1970 (odd, I know). Time.Sec will return the number of seconds since 1970. So you need to find out how many seconds are between 1970 and christmas 2008 and subtract that from what you got from time.sec. convert that to days/hours/minutes and you're good!

Author:  Tony [ Mon Dec 08, 2008 10:14 pm ]
Post subject:  Re: RE:countdown

insectoid @ Mon Dec 08, 2008 9:44 pm wrote:
Well, the Turing timer counts in seconds (milliseconds?) from 1970 (odd, I know).

It's not Turing, it's the system time, also known as POSIX time. It's a well known fact that time began on January 1st, 1970; And that time will end on January 19, 2038 -- http://en.wikipedia.org/wiki/Year_2038_Problem

Author:  rdrake [ Tue Dec 09, 2008 12:31 am ]
Post subject:  Re: RE:countdown

ecookman @ Mon Dec 08, 2008 9:37 pm wrote:
i i dunno if it is vb net

just says visual basic express edition so i went to the unforgiving "beast" of turing...


turing codes would be helpful i know nothing about C#... i have looked and ripped some scripts (changing values in variables) but nothing major


p.s thanks for your time
The same classes are shared between C# and VB.NET. I guarantee you 99% of that code will work unmodified in a VB.NET application. Just remove the semicolons to dumb down the syntax a bit.

Author:  gianni [ Tue Dec 09, 2008 2:37 am ]
Post subject:  RE:countdown

UNIX EPOCH

Author:  ecookman [ Tue Dec 09, 2008 10:50 am ]
Post subject:  RE:countdown

^
post |
|with
related|
|and useful
substance|please Very Happy

*smacks head off desk*


this isn't helping if someone could start the code....i am really lost i know nothing about these functions AND i still do not understand the math


p.s the helpdesk in turing doesnot work for me

Author:  gianni [ Tue Dec 09, 2008 11:00 am ]
Post subject:  RE:countdown

Okay dude, I don't mean to be an asshole or anything, but 2 people have already told you *exactly* what you need to do. And you have even been given at least 2 working code examples as well.

Not knowing a certain language or feature of said language is irrelevant.

You have a problem, they have given you the steps to solve the problem, you need to piece it together.

Solution: You have 2 dates (now and Christmas) all you need to do is find the difference. That will give you time remaining until Christmas.

Author:  ecookman [ Tue Dec 09, 2008 5:41 pm ]
Post subject:  RE:countdown

yes but I for one like to understand what the code is doing...

I DON'T have vb.net...i don't have Ruby
i tried to get ruby...but it doesn't work for me.

soo guess what that is why i moved this to the TURING section... makes sence right


i have tried to make one and failed...i have googled it and you guessed it failed . That is why i have asked for someone to start off the code and tell me how to use the different functions....

I am a beginner to programming sooo my syntax and source code skills aren't that good (only about 4 months i have been programming)


you might be a expert programmer, but i am not...if you have a solution please help...if i understood what to do i would have already


as md said to me....be a problem solver and use decisive thinking. (if you think about it i wouldn't still be on this problem if i had understood the first time...right???)


so please. If you have any input to my problem...share Very Happy

Author:  gianni [ Tue Dec 09, 2008 5:48 pm ]
Post subject:  RE:countdown

If you read the end of my last post just after "Solution:" you'll see that I have told you exactly what you have to do. It's not even pseudo-code, it's plain english.

So, after reading that, logical thinking will lead you too research date handling in your language of choice. From there you might find out how to perform basic mathematical functions with dates. Now by this point ... you are done.

Author:  ecookman [ Tue Dec 09, 2008 6:22 pm ]
Post subject:  RE:countdown

as i have said before i have tried that please, you are starting to troll

Author:  [Gandalf] [ Tue Dec 09, 2008 6:31 pm ]
Post subject:  RE:countdown

What exactly is it that you don't understand? Everyone could be a lot more helpful if you'd be a bit more specific than that you don't get it and you've googled it.

I'm assuming you can't find the functions you need. For this, all you need is to search through the Turing Documentation. You have:
Quote:
Syntax Time.PartsSec (year, month, day, hour, minute, second : int) : int

Description The Time.PartsSec function is used to convert the numeric parts of a date (specifically the year, month, day, hour, minute and second) into the number of seconds since 00:00:00 GMT Jan 1, 1970 and the date specified by the parts.

And Time.Sec, which has already been mentioned:
Quote:
Syntax Time.Sec : int

Description The Time.Sec function returns the current date and time as a number. The returned integer is the time in seconds since 00:00:00 GMT (Greenwich Mean Time) January 1, 1970.

Now, subtract both values and you have the time in seconds. From there, it's grade 2 work to figure out the amount of days.

Author:  ecookman [ Tue Dec 09, 2008 6:36 pm ]
Post subject:  RE:countdown

yes sorry IT was referring to the problem thanks that worked...how would i make thins into a "count down clock" like the one showed to me in ruby and vb net...any clues

Author:  [Gandalf] [ Tue Dec 09, 2008 6:38 pm ]
Post subject:  RE:countdown

By putting it in a loop and displaying the resulting value each time.

Author:  S_Grimm [ Tue Dec 09, 2008 7:27 pm ]
Post subject:  RE:countdown

ie

Turing:

loop
%code here
end loop


and, ecookman, gianni was not starting to troll. You just don't understand english enough to comprehend what he was telling you.

Author:  Insectoid [ Tue Dec 09, 2008 9:07 pm ]
Post subject:  Re: RE:countdown

ecookman @ Tue Dec 09, 2008 5:41 pm wrote:
yes but I for one like to understand what the code is doing...

We have told you what the code is doing.

Quote:

i have tried to make one and failed

Everyone almost always fails the first time. The secret is to try again.

Quote:

you might be a expert programmer, but i am not...if you have a solution please help...if i understood what to do i would have already

Once, he was far from an expert programmer. However, he asked for help, not code, and figured it out himself. That's why he's an expert now.

Quote:

as md said to me....be a problem solver and use decisive thinking.

I think you're missing the point here...YOU are supposed to be a problem solver. You are asking US to solve the problem for you (and we HAVE, several times).

If you are having so much trouble with this, start smaller. Do some easy projects to get the feel of the Time class. I admit, in grade 10 (you re in grade 10, right?), the goal is to develop skills in solving these problems. I have no issues telling you exactly how to do it, and how it works. Without supplying code. In my class, my teacher only gives us commands, we have to figure out the logic ourselves. Most people get it (even sorting) with no external resources. The rest come to me Razz. The point is, these people did these assignments with ONE WEEK of programming. You had 4 months. You can figure it out.

Author:  ecookman [ Wed Dec 10, 2008 11:03 am ]
Post subject:  RE:countdown

(sorry if this is a doubble i can't see the last post i put...i am not sure if i even hit reply) sorry it was refering to the problem and the countdown timer it self



thanks for the help i no now know how the function works...but i can't make it work...lol
it pretty much says i am missing lotsa stuff like this hasn't been declared that doesn't work what is this...what are you doing...

Author:  gianni [ Wed Dec 10, 2008 11:07 am ]
Post subject:  RE:countdown

Hey, perhaps if you paste what you have so far people could give you a hand?

Author:  ecookman [ Wed Dec 10, 2008 8:12 pm ]
Post subject:  RE:countdown

yes insectoid...i have had some time to play with turing ...but what we did was very...very...very basic.didn't even touch boolean

pretty much the most complex thing we did were for loops.....
I am working on a revised code that i think will work


soup and Saad cleared up some of the foggy areas for me

Author:  ecookman [ Thu Dec 11, 2008 11:31 am ]
Post subject:  RE:countdown

o.k i am strting a new topic called

" Christmas timer"

this has the timer i have so far..it counts....IT LIVES


but only tells you the time and date

Author:  ecookman [ Thu Dec 11, 2008 11:42 am ]
Post subject:  Christmas Timer

this is the uncluttered topic of the Countdown timer...

this is what i have so far (took me and a friend to get this :s)

Turing:

loop

var DT, Ddate, Ttime : string
var f1 : int := Font.New ("airial:25:bold")
        DT := Time.Date
        Ddate := DT (1 .. 9)
        Ttime := DT (11 .. *)
       
        Font.Draw ("The date and time today is ", [X], [Y], f1, black)
        put Time.Date
       
     
        delay (1000)
        cls
end loop




problems:

1) font is not drawing only displays Time.Sec

2) still can't figure out the "countdown" part of this...i finally understand the 1970 the amount of time since then ...i thought it was a magical number



p.s as people have been saying i have had time to play around with turing AND i have lots of Knowledge about this....well this wis the most complex thing i have done so far... Smile

Author:  Insectoid [ Thu Dec 11, 2008 4:11 pm ]
Post subject:  Re: RE:countdown

ecookman @ Wed Dec 10, 2008 8:12 pm wrote:

soup and Saad cleared up some of the foggy areas for me


Just pointing this out, but Soup is insectoid. I don't have to use the same nickname on the board and the irc, do I?

Glad to see you're understanding the concepts now. Learning process in motion, guys!

Author:  ecookman [ Fri Dec 12, 2008 10:24 am ]
Post subject:  RE:countdown

O.O


Very Shocked

i didn't know you could do that
...thanks for help on the math lol
-------------------------------------------------
o.k i have hit a total road block i don't know what to do from here and my friend was like hmmmmmmmmmmmmmmmmmm
screw it i don't know


sooooo i am trying to piece bits of knowledge together but i find myself going in circles


if someone is willing to give me a little boost or a example of the syntax i should use next...you will save me lots of money on advil

and why isn't my Font.Draw working


but until then, away i GOOOOOOOOOO

p.s ii realize what i have to do...with the subtracting dates...but i don't know how i do that. (in code)

Author:  Insectoid [ Fri Dec 12, 2008 2:27 pm ]
Post subject:  RE:countdown

Okay, putting lots of m's and o's at the end of words won't make us help. In fact it does the opposite.

Why not show us what you have so far, and then we can work from there?

Author:  isaiahk9 [ Fri Dec 12, 2008 3:38 pm ]
Post subject:  RE:countdown

@ecookman - this is the third time I've recommended that you check other threads. Why did you start a new one, when there are many others out there (ex - I think that someone was working for about 2 weeks on how to create a countdown for the olympics). Please don't create clone threads.

Author:  ecookman [ Fri Dec 12, 2008 3:53 pm ]
Post subject:  RE:countdown

Isaiak i looked at that one and it confused me more

Insectiod refer above...that is the working copy i have i can't seem to go farther than that or are you looking for the one (that i got rid of but can remake) that doesn't work and fix it???

Author:  isaiahk9 [ Fri Dec 12, 2008 4:03 pm ]
Post subject:  RE:countdown

You confuse me. Or I confue you. I didn't really care about your timer. I was just saying that you have a habit of making new threads without looking at old ones (at least, that's what it looks life). A quick search told me that there were about 3 similar problems, 1 similar tutorial and 1 similar submission (or more).
If you really did look through them, and still felt the need to start this new thread . . . you'd probably look alot better if you said you hadn't looked at all.

Author:  ecookman [ Fri Dec 12, 2008 7:59 pm ]
Post subject:  RE:countdown

i searched "countdown" and only found the confusing Olympics thing

Author:  isaiahk9 [ Fri Dec 12, 2008 8:21 pm ]
Post subject:  RE:countdown

k . . . I meant with a little thinking. With a little ingenuity, you can find the exact same problem, even when it is not clearly labeled "countdown".

Author:  ecookman [ Fri Dec 12, 2008 8:22 pm ]
Post subject:  RE:countdown

well i searched the pages and i guess i am stupid

link please

Author:  isaiahk9 [ Fri Dec 12, 2008 8:51 pm ]
Post subject:  RE:countdown

It's not stupidity. It's just you have trouble finding stuff. I'm like that in real life.

Unfortunately, I don't really have the time to go searching through the Turing problems/tutorials/submissions. (I bet for a lot of people, they think I'm just avoiding empty flaunts and brags).

So I'll tell you how. Run several searches with related names like "countdown", "timeline", etc. Take have a dozen to a dozen and a half of the results and quickly browse through them to see if they are your problem. If they don't, rinse, wash and repeat. If they still don't after awhile (in all 3 categories), then its time to create your own thread.

Sorry for empty accusations before.

And if your problem was solved already, then this really doesn't matter.

Author:  ecookman [ Sun Dec 14, 2008 2:03 pm ]
Post subject:  RE:countdown

AAARRRGGGGGG i can't figure this out



t.t



if someone could finish it off for me...you will be my god..

at this rate ill probably be done next yeas sometime

Author:  isaiahk9 [ Sun Dec 14, 2008 4:08 pm ]
Post subject:  RE:countdown

A) We don't give away answers.
B) Don't call people God. It really upsets religious people.
C) The Olympics thing is just what you're looking for. You need to access the computer with its time functions (to check the current date), subtract them from the wanted date/time and then start a countdown,( a 1000 millisecond delay subtracting seconds, and then minutes, then hours, etc.)
What are you having trouble with?

Author:  DanielG [ Sun Dec 14, 2008 4:22 pm ]
Post subject:  Re: countdown

I will say again what many said before me, using turing`s Time.DateSec and Time.Sec (look them up in turing help file for explanation as to what they do), those, and simple divison (and mods) are all you need for this.

Author:  isaiahk9 [ Sun Dec 14, 2008 4:25 pm ]
Post subject:  RE:countdown

@Bean : What the? Why did you neeed to announce that?

@Ekookman : DanielG has all the answers you need. Now you just need to F10 it, we can't help you anymore.

Author:  ecookman [ Sun Dec 14, 2008 7:18 pm ]
Post subject:  RE:countdown

1) font is not drawing only displays Time.Sec

2) i know the math but i have no clue how to set it up. Sorry, but i have no clue i have looked at the Olympics thing and it is no help.

3) i don't know what mods are


no saying someone has to do this, but if you give me the code...i will break it down and explain it back to you guys just so you know that i didn't blindly copy and paste...heck if you want ill make a tutorial out of it...once i understand the code.

Author:  isaiahk9 [ Sun Dec 14, 2008 7:44 pm ]
Post subject:  RE:countdown

1) I don't really know much about Time.Sec. Better luck with DanielG.

2) Basically, using the Time functions (once you figure them out) you set variables for the current time. Then, you subtract the time you're looking for from the given time. that gives you the amount of time until your goal. Then, use a loop with a delay of 1000 milliseconds in it. In the loop, you wanna go something like this :
Seconds = seconds - 1
If seconds = 0 Then
Seconds = 60
Minutes = minutes - 1
End If
% Same for minutes, hours, days, etc.

Then, you display the seconds, minutes, hours, etc. This shows you how much time until the time you're looking for.

3) Mod is a function like division. When you go :
5 / 2
in Turing, you get 2.5.
But Mod divides the number only as many times as it is whole numbers. So it returns the remainder. So :
5 / 2 = 2.5
5 Mod 2 = 1 % 5 can only divided by 2 twice, so 4. Therefore the remainder is 1.

. . . hope that helps.

Author:  gianni [ Sun Dec 14, 2008 8:09 pm ]
Post subject:  RE:countdown

Sometimes, when I encounter a difficult programming problem, I'll grab a pen & paper and write down what I think I should do and how I am going to approach the problem in a way that makes sense to me. It's a good way to visualize your solution and keep yourself on track.

Author:  ecookman [ Sun Dec 14, 2008 8:21 pm ]
Post subject:  RE:countdown

o.k???? but how would i do that with the program i have already written isaiahk?



gianni-already done lol

Author:  isaiahk9 [ Sun Dec 14, 2008 10:14 pm ]
Post subject:  RE:countdown

You have two ways to take this news : it would be better to start over.
Bad way : All that work didn't really count for much.
Good way : Starting fresh and using the pointers collectively from me, DanielG and the Olympics Rings Program, this is much shorter. This entire program can actually be done in less than 50 lines. (probably less than 30).

That's my advice, but keep your old one in case if you do restart.

And what's this for anyway (& when is it due)?

Author:  ecookman [ Sun Dec 14, 2008 10:24 pm ]
Post subject:  RE:countdown

due: asap...before x-mas
for: a race between my friend and i to make the best countdown timer before x-mas....able to use any means necessary to win...cheating is allowed...eracing cdrive is allowed...lol anything goes pretty much

i was trying to make a simple user interface where the user could just enter a date into the code and from there it counts down...is that possible

Author:  isaiahk9 [ Sun Dec 14, 2008 10:39 pm ]
Post subject:  RE:countdown

Yup, that's possible.

. . . erasing the C Drive is allowed?
Wow.
If it's going that far, and you've spent weeks on it, and you have no ethics, I would try something else :

Laze about, and goof off until Christmas. If cheating is allowed, the day before your contest is happening, steal it. Delete it off his memory, and copy it unto yours. Make a hard copy (CD, USB, external hard drive), and carry it on your person. Then, switch up headers, comments, variable names and order of non-sequential code.

. . . nah, just kidding. That would be evil and immoral. . . if there is a difference.

Anyways, yeah you can do. Read my above post(s) for a recommendation of doing it, if you think I gave sound advice.

Author:  DanielG [ Sun Dec 14, 2008 10:57 pm ]
Post subject:  RE:countdown

I finished the regular version of this (you put in the code) in 15 lines (and I have a white space), and could also finish it with less (but that would make the code unclear).

read up in the turing tutorial on Time.Sec and Time.DateSec (read up on the version of this where you input the date), if you haven't read those yet you shouldn't be complaining that you don't get it, and if you did, you should at least say you don't get that specific function and how it works

If you get both of thos and just don't get how to convert the time in seconds till that date to days, hours, minutes , seconds. You should write that

We need to know what you are having trouble with in order to help.

Edit1: fixed typo

Author:  isaiahk9 [ Mon Dec 15, 2008 5:39 am ]
Post subject:  RE:countdown

15 lines? Good job.

Author:  ecookman [ Mon Dec 15, 2008 8:11 am ]
Post subject:  RE:countdown

...put me to shame...


thanks and wow 15 lines Very Shocked

Author:  ecookman [ Mon Dec 15, 2008 5:56 pm ]
Post subject:  RE:countdown

i got the help desk to work...yay

Turing:
% The "Time.SecStr" program.
setscreen ("text")
put Time.SecStr (Time.Sec, "A B d, Y,z,Z"),
    Time.SecStr (Time.Sec, "j"), " of ", Time.SecStr (Time.Sec, "Y")



from this and the one i did before how would i combine these

Mod Edit: Remember to use syntax tags!
code:
[syntax="Turing"]Code Here[/syntax]

Author:  ecookman [ Wed Dec 17, 2008 12:00 pm ]
Post subject:  the christmas countdown advanced troubles

thanks to The_bean i have now completed the countdown timer.


problem: the base of the program works. but what i want it to do is when you press y it takes you to the total number of seconds and then counts down from there. if you press n it shows you:
_days
_hours
_mins
_sec


what i want it to do is press y shows the total shows the total secs...press n shows it in the above format...
what i want it to do: while it is running if you want to switch from one to the other simply press y or n depending which "mode" you are in and then it continues the countdown.so press y it shows the total seconds counting down and while it is counting if you press n it goes to the days..hours...ect.




simple right.....NOT


what is happening: when the program first starts you have to press y or n once press enter then again...then it shows you the program for one second and goes back to "do you want ot see the total number of seconds"




so here is the code

if someone can fix it or show me how that would be greatly appreciated






Turing:


  colorback (black)
  color(brightgreen)

    get yn
    if yn = "yes" or yn = "no" then
        exit
    else
        get yn
    end if

if yn = "y" then
colorback (black)
color (brightgreen)
 

    var total : int := days * 86400 + hours * 3600 + mins * 60 + secs
    colorback (black)
    color (brightgreen)
    put total
    delay (1000)
    cls
end if
if yn = "n" then
 
    f1 := Font.New ("Airil:12:bold")
   
    colorback (black)
    color (brightgreen)
    Font.Draw (intstr (days) + " DAYS", maxx div 3, 250, f1, brightgreen)
    Font.Draw (intstr (hours) + " HOURS", maxx div 3, 200, f1, brightgreen)
    Font.Draw (intstr (mins) + " MINUITES", maxx div 3, 150, f1, brightgreen)
    Font.Draw (intstr (secs) + " SECONDS", maxx div 3, 100, f1, brightgreen)
    delay (1000)
    cls
end if
end loop

Author:  Insectoid [ Wed Dec 17, 2008 12:41 pm ]
Post subject:  RE:the christmas countdown advanced troubles

Why not post this in your original thread?
This is about the exact same program, it goes in the exact same thread.

We'll call this a merge request.

Author:  ecookman [ Wed Dec 17, 2008 4:42 pm ]
Post subject:  RE:countdown

sorry...different program...and partof this one got cutoff


: