Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 i don' even know what to call this
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ecookman




PostPosted: Wed Mar 25, 2009 10:30 am   Post subject: i don' even know what to call this

well, the curse of the countdown timer has come to haunt me again T_T
my friend wants me to make another one....except the user of the program enters the time to countdown time to, instead of it being a fixed time and date

Turing:

var Day : string
put "enter the date and time in this format: dd (jan,feb..) yy hh:mm:ss"
get Day

%var Day : string := "31 Mar 09 00:00:00"
loop
    var totalseconds : int := Time.DateSec (Day) - Time.DateSec (Time.Date)
    var days, hours, mins, secs : int


    days := totalseconds div 86400
    totalseconds := totalseconds - days * 86400

    hours := totalseconds div 3600
    totalseconds := totalseconds - hours * 3600

    mins := totalseconds div 60
    totalseconds := totalseconds - mins * 60

    secs := totalseconds

    var total : int := days * 86400 + hours * 3600 + mins * 60 + secs
    var f1 : int
    f1 := Font.New ("Airil:56:bold")

    colorback (black)
    color (brightgreen)
    Font.Draw (intstr (days) + " DAYS", maxx div 6, 320, f1, brightgreen)
    Font.Draw (intstr (hours) + " HOURS", maxx div 6, 220, f1, brightgreen)
    Font.Draw (intstr (mins) + " MINUITES", maxx div 6, 120, f1, brightgreen)
    Font.Draw (intstr (secs) + " SECONDS", maxx div 6, 15, f1, brightgreen)
    delay (1000)
    cls
end loop


so my problem is in the first 3 lines...how can i get the entered info to be used as the date and time...

---------------------------------------------------edit-------------------------------------------
typos
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Wed Mar 25, 2009 12:13 pm   Post subject: Re: i don' even know what to call this

You can approach that part is several ways: For one you can do it as you have, all in one string. Or you can break it up into its elements, and ask for each part separately (ex: "Enter the Month: "). Although breaking it up requires less string manipulation (although nothing too much), it also allows for easier error checking. So you can easily have a loop for each section to make sure they enter a valid number before moving on. Just an idea.

Ex:
Turing:
var day, month, year : string

loop
    put "Enter a valid day: "..
    get day
    exit when strintok (day) and strint (day) > 0 and strint (day) <= 31
end loop


But to be more specific, does the user enter a time for it to count down, or a date (and time) to count down to?
ecookman




PostPosted: Wed Mar 25, 2009 4:24 pm   Post subject: RE:i don\' even know what to call this

the Time.DateSec function needs to have the date and then the time....and that part that you put above....is way over my head...i just know the basics
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: