Page 1 of 1

about timers

Posted: Sat Jan 10, 2015 3:07 pm
by brandcode
i have 10 fields with different appointments in every field.
field 1 have start time 12:00 and end time 12:15
field 2 have start time 12:00 and end time 12:30
field 3 have start time 12:30 and end time 13:00
Is possible to check every 5 min the fields and send the info to user ?
thank you

Re: about timers

Posted: Sat Jan 10, 2015 5:41 pm
by jmburnod
Hi brandCode,
Is possible to check every 5 min the fields and send the info to user ?
Yes. :D
You probably have to write a "send in time" loop.
Have a look to "send" in the LC dictonary
Best regards
Jean-Marc

Re: about timers

Posted: Sat Jan 10, 2015 5:57 pm
by dunbarx
Hi.

So much fun. I do not know how your start time and end time are placed in your fields. Are they two words? Two lines? It matters, because we want to be able to access both pieces of information.

Now, the convert command will take a value like "12:15", and assume it is on the current day. But this means that a "common denominator" can be thought of being present in each field, so that only the "local" value need be considered. This is a good thing. In other words, as a test, make two fields, one with "12:15" in it, and one with "12:30" in it. Now try this in a button:

Code: Select all

on mouseUp
   put fld 1 into early
   put fld 2 into later
   convert early to seconds
   convert later to seconds
   answer later - early
end mouseUp
The "900" you get is the 15 minute difference between the two values. See? The time can be dealt with on a strictly "local" value level.

But now ON A NEW CARD make another field, and put a time that is a minute in the future. Now try this in button on that card:

Code: Select all

on mouseUp
   startChecking
end mouseUp

on startchecking
   put the seconds into line 2 of fld 1
   repeat with y = 1 to the number of flds
      get fld y
      convert line 1 of it to seconds
      if the seconds - it > 0 then
         answer "You are late"
         exit to top
      end if
   end repeat
   send "startChecking" to me in 1 second --This might be "600 seconds" in your actual app.
end startchecking
Your homework is to figure out what all this is doing, and write back with how you are making your app work.

Craig Newman