RE Loading a button with Time

Dave Herndon herndogy at sbcglobal.net
Tue Oct 31 00:30:50 CST 2006


WOW !  John Craig's script made mine look STINKY !!  I made a couple changes to it to suit my needs.  It now formats the contents to load dirrectly into a cascading style pull down button so it is easy to select the time you want.  I reformated the script to span 24 hours and maintain a military 0800 style format.  This will make it easy to quickly change the increments.  Some agencies round to the quarter hour and others to the 5 or 10 minute mark so very cool.  Thanks John !  Here is the revised script. Uses three fields to spec the operation and a pull down menu button which gets loaded with 288 lines of time increments spanning from 0000 to 2400 hrs . 
  Field "Start1" = 0:05 AM, "end1" = 11:55 pm , "Int1" = 5
  the pull down menu is "Time Menu"
  Put the script below into the "Load" button script
   
  on mouseUp
  put fld "start1" into tStart
  put fld "end1" into tEnd
  put fld "int1" into tInterval 
  put empty into tData 
  convert tStart to dateItems 
  convert tEnd to dateItems
  put item 4 of tStart * 60 + item 5 of tStart into tStartSecs
  put item 4 of tEnd * 60 + item 5 of tEnd into tEndSecs
  put tStartSecs into tSecs
  repeat while tSecs <= tEndSecs
  put tSecs into tTime
  convert tTime from seconds to dateItems
  put item 5 of tTime into tHour
  put item 6 of tTime into tMin
  if tdata <> empty then put return after tdata
  if the number of chars of tHour < 2 then put "0" & tHour into tHour
  if tMin is "00" then put tHour & ":" & format ("%02d", tMin) & return after tdata
  put tab & tHour & ":" & format ("%02d", tMin) after tData
  add tInterval to tSecs
  end repeat
  put return & tab & "24:00" after tData
  put tData into button "Time Menu"
  end mouseUp 



More information about the use-livecode mailing list