Countdown to event "how many minutes left"

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by kibbitzer, May 16, 2009.

  1. kibbitzer

    kibbitzer

    Joined:
    Nov 25, 2004
    Messages:
    8
    Likes Received:
    0
    Location:
    Sydney, Australia
    G'day All,
    I'm trying to display, in a CTC control (written to by a user defined System I/O variable), the AMOUNT of time, expressed in minutes and seconds (and optionally, hours) until sunrise, sunset or a particular time of day. At this satge, I only wish to have a maximum of 60 minutes maximum before the event (hours seem to be a lot more difficult).

    global variables:
    intTime2event := integer
    strTime2event := string

    Module:
    {*********** start of code **************}
    begin
    intTime2event := sunset - "01:00:00" - time; {one hour before the event: sunset}
    TimeToString(intTime2event, strTime2event);
    SetStringSystemIO("Time to Event", strTime2event);
    {Delay(60); in case I want to refresh the display once a minute}
    end;
    {*********** end of code **************}

    This results in a 'time of day' displaying. The minutes count down correctly, but the 12H and AM are unwanted.

    Is there a way to truncate/extract the string so that only the minutes and seconds portion of the string are written to the variable?

    or...

    Can I get around this by somehow initialising and starting a timer, set by schedule, at a particular time and displaying the results?... I know that timers only count UP... so I'm in the dark! (not very punny!)

    Regards,

    Peter.
     
    kibbitzer, May 16, 2009
    #1
  2. kibbitzer

    Dave Byron

    Joined:
    Aug 3, 2004
    Messages:
    835
    Likes Received:
    0
    Location:
    Casurina
    Peter

    Look up the copy command, you can extract bytes with starting position and length parms. i do this to get just hours and min

    dave


    TimeToString(time, Long_time);

    if length(Long_time) = 10 then
    Copy(Short_time, Long_time, 1, 4)
    else
    Copy(Short_time, Long_time, 1, 5);
    end;
     
    Dave Byron, May 17, 2009
    #2
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.