
-----------------------------------
ecookman
Wed Mar 25, 2009 10:30 am

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


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

-----------------------------------
SNIPERDUDE
Wed Mar 25, 2009 12:13 pm

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:var day, month, year : string

loop
    put "Enter a valid day: "..
    get day
    exit when strintok (day) and strint (day) > 0 and strint (day) 