Re Subject: Adding Time

Dave Herndon herndogy at sbcglobal.net
Mon Oct 30 21:41:38 EST 2006


  Regarding >
  >Can anyone steer me in the correct direction for this?  What I need to
>o is populate a list box with times at specific intervals.  i.e.
 >
>I have a input box for the start time say 8:00 A.M.
>I have a input box that has a stop time say 5:00 P.M.
>I have a input box that has an interval say 5 minutes.
 
>What I want to do is populate a list box with:
 
>8:00 A.M.
>8:05 A.M.
>8:10 A.M.
>etc.
>etc.
The script below worked for me.  It returns the format below for a 24 hour period at 15 min intervals.  I had to do some minor editing to it to get perfect before I inserted it as the contents of a button.  I'm not proud of the script but it got the job done for me.  If you need the script that compares the difference between two of these numbers and compares them against a 24 hour period let me know.  Comparing say 0800 and 1315 and returning 5.25 Hrs.  I am a Firefighter and we work 24 hour shiftso I use the script often.
  script returns...
  0000
  0015
  0030
  0045
  0100
  0100
  0115
  0130
  0145
  0200
  0200
  0215
  up to 2400 hrs
   
  on mouseUp
  put 0 into daTime
  put "0000" into line 1 of field "hr select"
  repeat with x = 2 to 119
  put daTime + 15 into DaTime
  if DaTime is "60" then
  put "100" into daTime
  put DaTime into line x of field "hr Select"
  add 1 to x
  put tab & DaTime into line x of field "hr Select"
  next repeat
  end if
  if the number of chars of daTime < 4 then
  if char 2 to 4 of DaTime is "60" then
  put "00" into char 2 to 4 of DaTime
  put char 1 of daTime + 1 into char 1 of daTime
  end if
  else
  if char 3 to 5 of DaTime is "60" then
  put "00" into char 3 to 5 of DaTime
  if char 2 of daTime is "9" then
  put "2000" into daTime
  put DaTime into line x of field "hr Select"
  add 1 to x
  put tab & DaTime into line x of field "hr Select"
  next repeat
  end if
  put char 2 of daTime + 1 into char 2 of daTime
  end if
  end if
  if the number of chars of daTime > 2 then
  if char 2 to 3 of DaTime is "00" then
  put DaTime into line x of field "hr Select"
  add 1 to x
  put tab & DaTime into line x of field "hr Select"
  next repeat
  end if
  end if
  if the number of chars of daTime > 3 then
  if char 3 to 4 of DaTime is "00" then
  put DaTime into line x of field "hr Select"
  add 1 to x
  put tab & DaTime into line x of field "hr Select"
  next repeat
  end if
  end if
  put tab & DaTime into line x of field "hr Select" ---- puts all the times into a field called hr select
  end repeat
  end mouseUp



More information about the Use-livecode mailing list