5 Replies Latest reply on Nov 21, 2006 1:54 PM by Newsgroup_User

    checking the time

    Level 7
      Hi Director people,

      I am trying to write a short script that isn't working for me. I have a
      time set for something to happen (eg 12:00PM). And, if the system clock
      passes that time, I want to initiate some other Lingo. But, am having
      trouble just checking if the current time is passed my set time.

      I've tried
      if _system.time() > myTime then ....
      but that isn't working. So, how should I be doing it?

      Thanks.

      John

        • 1. Re: checking the time
          Applied CD Level 1
          _systerm.time() returns a string, not a numeric value … so when you test _system.time() > myTime all you’re getting is the comparison of two strings. To compare time you need either numeric values or a date object. You could parse the string to get a numeric value but Buddy API makes it easier. With Buddy API you could do something like this:

          currentTime = value(baSystemTime(%0H%0M%0S))
          myTime = 120000

          if currentTime > myTime then…

          If you choose to use a date object be aware that only the Java Script syntax supports time, the lingo version is for dates only.
          • 2. Re: checking the time
            James Newton, ACP Level 3
            Try something like this:


            global gTime

            on alertWhenTimePasses()
            gTime = the systemDate
            gTime.seconds = gTime.seconds + 60 -- 60 seconds from now
            vPeriod = 10 * 1000 -- check every 10 seconds

            vTimeOut = timeOut().new("TimePassing", vPeriod, #timesUp)
            end alertWhenTimePasses


            on timesUp(dummy, aTimeOut)
            vTimeNow = the systemDate
            if vTimeNow >= gTime then
            if vTimeNow.seconds > gTime.seconds then
            aTimeOut.forget()
            alert "It is time..."
            end if
            end if
            end timesUp
            • 3. Re: checking the time
              Level 7
              Applied CD wrote:

              > _systerm.time() returns a string, not a numeric value ? ...
              >
              > ..... You could parse
              > the string to get a numeric value but Buddy API makes it easier.

              Thanks for that. But, need to have this happen in Shockwave. I didn't follow what
              you meant in the for Java Script syntax.



              • 4. Re: checking the time
                Level 7
                Hi,

                I actually need to do something relatively simple. Right at the start of
                the movie, need to check the time and then show something on screen
                based on that time. I have morning information and afternoon information
                tthat will show in my DCR. But, I want to define the tme when afternoon
                information starts. Sometimes it may be 12pm, other times 1pm. So, want
                to check the current time against my variable time and then load teh
                right info at eh start.

                Thanks.

                • 5. Re: checking the time
                  Level 7
                  Thanks both for your help.

                  I think I'll do it in the following way:
                  * check current time in seconds using: (the systemDate).seconds
                  * convert defined time like '12:00pm' to seconds by just separating the
                  hours and minutes and then having a mathematical equasion to convert it to
                  seconds.

                  Both the above replies have been helpful in getting me to a solution.