KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: A simple way to fill out a time drop-down variable
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: November 8, 2005
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

If you want a time variable on your form, but don't want to worry about formatting during user entry. All you need is a FOR loop and a drop-down object to place on your form.

1) Add the drop-down object to your form.
2) Set its "Type" to "Time". It is a text array, but it displays a time.
3) Leave the Display "Time Format" as "HH:MM". The formatting is handled already.
4) Then call the following code On Load or based upon your program flow.

When saving the time the user selected, you only have to procedurally save the array's current value to an integer field, since the time array will never have different elements.

C_LONGINT($timeIntervals;$i)

C_TEXT($timeString)

ARRAY TEXT(aScheduleTime;0)

DELETE ELEMENT(aScheduleTime;1;Size of array(aScheduleTime))

$timeIntervals:=(24*4)-1  ` 24 hours, 4 quarters in an hour, skip midnight

For ($i;0;$timeIntervals)

  $timeString:=Time string(15*60*$i)

  APPEND TO ARRAY(aScheduleTime;String(Time($timeString);HH MM AM PM ))

End for