Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 7 of 7

Thread: Clock Help

  1. #1
    Join Date
    Mar 2006
    Posts
    2

    Oops Clock Help

    Can anyone give the script or code to put a simle clock on my project.
    I want to run it with a border or flat. Digital preferably.I need to get system time but dont know how to write it.If I just put in get system time on startup
    it shows nothing. Something so simple makes me feel so stupid

    Thanks for any Help
    Jim

  2. #2
    Join Date
    Feb 2005
    Location
    Mn
    Posts
    770
    HaVe a look here.

  3. #3
    Join Date
    Mar 2004
    Location
    Toronto, ON CANADA
    Posts
    696
    Here's my contribution. I was using a Flash clock until a little while ago in one of my applications, but I didn't want to have any Flash dependencies, just for a clock.

    On Startup:
    Code:
    sdayofweek1 = "Sunday";
    sdayofweek2 = "Monday";
    sdayofweek3 = "Tuesday";
    sdayofweek4 = "Wednesday";
    sdayofweek5 = "Thursday";
    sdayofweek6 = "Friday";
    sdayofweek7 = "Saturday";
    smonth1 = "January";
    smonth2 = "February";
    smonth3 = "March";
    smonth4 = "April";
    smonth5 = "May";
    smonth6 = "June";
    smonth7 = "July";
    smonth8 = "August";
    smonth9 = "September";
    smonth10 = "October";
    smonth11 = "November";
    smonth12 = "December";
    On Preload:
    Code:
    Paragraph.SetText("ParagraphTime", System.GetTime(TIME_FMT_AMPM));
    sdayofweek = System.GetDate(DATE_FMT_DAYOFWEEK);
    if sdayofweek == "1" then
    	sdayofweek = sdayofweek1
    elseif sdayofweek == "2" then
    	sdayofweek = sdayofweek2
    elseif sdayofweek == "3" then
    	sdayofweek = sdayofweek3
    elseif sdayofweek == "4" then
    	sdayofweek = sdayofweek4
    elseif sdayofweek == "5" then
    	sdayofweek = sdayofweek5
    elseif sdayofweek == "6" then
    	sdayofweek = sdayofweek6
    elseif sdayofweek == "7" then
    	sdayofweek = sdayofweek7
    end
    smonth = System.GetDate(DATE_FMT_MONTH);
    if smonth == "01" then
    	smonth = smonth1
    elseif smonth == "02" then
    	smonth = smonth2
    elseif smonth == "03" then
    	smonth = smonth3
    elseif smonth == "04" then
    	smonth = smonth4
    elseif smonth == "05" then
    	smonth = smonth5
    elseif smonth == "06" then
    	smonth = smonth6
    elseif smonth == "07" then
    	smonth = smonth7
    elseif smonth == "08" then
    	smonth = smonth8
    elseif smonth == "09" then
    	smonth = smonth9
    elseif smonth == "10" then
    	smonth = smonth10
    elseif smonth == "11" then
    	smonth = smonth11
    elseif smonth == "12" then
    	smonth = smonth12
    end
    sdaytemp = System.GetDate(DATE_FMT_DAY);
    nleadingzero = String.Find(sdaytemp, "0", 1, false);
    if nleadingzero == 1 then
    	sday = String.Right(sdaytemp, 1);
    else
    	sday = sdaytemp;
    end
    syear = System.GetDate(DATE_FMT_YEAR);
    Paragraph.SetText("ParagraphDate", sdayofweek.." "..smonth.." "..sday..", "..syear);
    On Show:
    Code:
    Page.StartTimer(250);
    On Timer:
    Code:
    Paragraph.SetText("ParagraphTime", System.GetTime(TIME_FMT_AMPM));
    sdayofweek = System.GetDate(DATE_FMT_DAYOFWEEK);
    if sdayofweek == "1" then
    	sdayofweek = sdayofweek1
    elseif sdayofweek == "2" then
    	sdayofweek = sdayofweek2
    elseif sdayofweek == "3" then
    	sdayofweek = sdayofweek3
    elseif sdayofweek == "4" then
    	sdayofweek = sdayofweek4
    elseif sdayofweek == "5" then
    	sdayofweek = sdayofweek5
    elseif sdayofweek == "6" then
    	sdayofweek = sdayofweek6
    elseif sdayofweek == "7" then
    	sdayofweek = sdayofweek7
    end
    smonth = System.GetDate(DATE_FMT_MONTH);
    if smonth == "01" then
    	smonth = smonth1
    elseif smonth == "02" then
    	smonth = smonth2
    elseif smonth == "03" then
    	smonth = smonth3
    elseif smonth == "04" then
    	smonth = smonth4
    elseif smonth == "05" then
    	smonth = smonth5
    elseif smonth == "06" then
    	smonth = smonth6
    elseif smonth == "07" then
    	smonth = smonth7
    elseif smonth == "08" then
    	smonth = smonth8
    elseif smonth == "09" then
    	smonth = smonth9
    elseif smonth == "10" then
    	smonth = smonth10
    elseif smonth == "11" then
    	smonth = smonth11
    elseif smonth == "12" then
    	smonth = smonth12
    end
    sdaytemp = System.GetDate(DATE_FMT_DAY);
    nleadingzero = String.Find(sdaytemp, "0", 1, false);
    if nleadingzero == 1 then
    	sday = String.Right(sdaytemp, 1);
    else
    	sday = sdaytemp;
    end
    syear = System.GetDate(DATE_FMT_YEAR);
    Paragraph.SetText("ParagraphDate", sdayofweek.." "..smonth.." "..sday..", "..syear);
    I hope this helps.

  4. #4
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    Hey Tek,

    You could reduce the number of evaluations in that code (and probably improve performance) by indexing the day/month names into tables and accessing them directly via their index.

    Something like this:

    On Startup
    Code:
    tdayofweek[1] = "Sunday";
    tdayofweek[2] = "Monday";
    tdayofweek[3] = "Tuesday";
    tdayofweek[4] = "Wednesday";
    tdayofweek[5] = "Thursday";
    tdayofweek[6] = "Friday";
    tdayofweek[7] = "Saturday";
    
    tmonth[1] = "January";
    tmonth[2] = "February";
    tmonth[3] = "March";
    tmonth[4] = "April";
    tmonth[5] = "May";
    tmonth[6] = "June";
    tmonth[7] = "July";
    tmonth[8] = "August";
    tmonth[9] = "September";
    tmonth[10] = "October";
    tmonth[11] = "November";
    tmonth[12] = "December";
    On Show/On Timer
    Code:
    Paragraph.SetText("ParagraphTime", System.GetTime(TIME_FMT_AMPM));
    
    sdayofweek = tdayofweek[System.GetDate(DATE_FMT_DAYOFWEEK)];
    smonth = tmonth[System.GetDate(DATE_FMT_MONTH)];
    sdaytemp = System.GetDate(DATE_FMT_DAY);
    
    nleadingzero = String.Find(sdaytemp, "0", 1, false);
    if nleadingzero == 1 then
    	sday = String.Right(sdaytemp, 1);
    else
    	sday = sdaytemp;
    end
    syear = System.GetDate(DATE_FMT_YEAR);
    Paragraph.SetText("ParagraphDate", sdayofweek.." "..smonth.." "..sday..", "..syear);
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  5. #5
    Join Date
    Mar 2004
    Location
    Toronto, ON CANADA
    Posts
    696
    Hi TJS,

    You're right... that would make it easier and probably faster, except for the fact that the month returned by System.GetDate(DATE_FMT_MONTH) returns two characters for the month. It would work for the day of the week though.

  6. #6
    Join Date
    Oct 2005
    Location
    MI
    Posts
    524
    This works better (good catch tek):

    Code:
    tdayofweek = {};
    tdayofweek[1] = "Sunday";
    tdayofweek[2] = "Monday";
    tdayofweek[3] = "Tuesday";
    tdayofweek[4] = "Wednesday";
    tdayofweek[5] = "Thursday";
    tdayofweek[6] = "Friday";
    tdayofweek[7] = "Saturday";
    
    tmonth = {};
    tmonth[1] = "January";
    tmonth[2] = "February";
    tmonth[3] = "March";
    tmonth[4] = "April";
    tmonth[5] = "May";
    tmonth[6] = "June";
    tmonth[7] = "July";
    tmonth[8] = "August";
    tmonth[9] = "September";
    tmonth[10] = "October";
    tmonth[11] = "November";
    tmonth[12] = "December";
    Code:
    Paragraph.SetText("ParagraphTime", System.GetTime(TIME_FMT_AMPM));
    
    sdayofweek = tdayofweek[String.ToNumber(System.GetDate(DATE_FMT_DAYOFWEEK))];
    smonth = tmonth[String.ToNumber(System.GetDate(DATE_FMT_MONTH))];
    sdaytemp = System.GetDate(DATE_FMT_DAY);
    
    nleadingzero = String.Find(sdaytemp, "0", 1, false);
    if nleadingzero == 1 then
    	sday = String.Right(sdaytemp, 1);
    else
    	sday = sdaytemp;
    end
    syear = System.GetDate(DATE_FMT_YEAR);
    Paragraph.SetText("ParagraphDate", sdayofweek.." "..smonth.." "..sday..", "..syear);
    Last edited by TJS; 05-25-2006 at 07:38 PM.
    Yeah right. Who's the only one here who knows the illegal ninja moves from the government?

    ()))))))))o)))))))==============================================

  7. #7
    Join Date
    Mar 2004
    Location
    Toronto, ON CANADA
    Posts
    696
    Now you're talkin'! That code works just fine, and I think I'll use it!

    Thanks TJS.

Similar Threads

  1. Is your clock Atomically correct?
    By Worm in forum AutoPlay Media Studio 6.0
    Replies: 29
    Last Post: 04-03-2009, 09:05 AM
  2. Atomic Clock snyc in you apps.!
    By Intrigued in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 05-29-2005, 09:10 PM
  3. System Clock Checking
    By HAZ in forum AutoPlay Media Studio 5.0
    Replies: 37
    Last Post: 12-03-2004, 07:32 AM
  4. Clock feature
    By Seraph_SGN in forum AutoPlay Media Studio 4.0
    Replies: 2
    Last Post: 09-10-2003, 06:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts