Here is a simple database to keep track of equipment downtime. It illustrates the use of code, some of the Newton's time and date functions, and logging of events. The fields are unit -- the piece of equipment in question down -- boolean, current state, is it down? down at -- int, readonly, time it last went down (encoded in seconds since midnight, 1 Jan 1993) up at -- int, readonly, time it last came back up (encoded in seconds since midnight, 1 Jan 1993) or 0 if it is currently down most recent -- int, readonly, duration of most recent downtime in seconds cummulative -- int, accumulated downtime log -- text, textual log of down and up events All the activity is confined to the "down" field. Change it to true, indicating the unit is down, and 1. "down at" will be filled in with the current time, 2. "up at" will be cleared. Change "down" to false, and 3. the down event will be logged in the "log" field. Change "down" to false indicating the unit is back up, and 1. "up at" will be filled in with the current time, 2. "most recent" will be filled in with the time lapse between "down at" and "up at", 3. "cummulative" will be incremented by "most recent", and 4. the up event will be logged in the "log" field. The log field looks something like: down at 4/30/94 3:02 pm up at 4/30/94 3:03 pm down at 4/30/94 3:04 pm up at 4/30/94 3:04 pm down at 4/30/94 3:23 pm up at 4/30/94 3:23 pm that is, the times are only recorded to the nearest minute, even though the downtime is calculated to the second. This is because the Newton's builtin time and date displaying functions expect time in minutes. It would be possible to append the number of seconds to the log line (see below). Of course if one wasn't that concerned about timing to the second one could keep time to the minute by changing the calls to TimeInSeconds() below to calls to Time(). Here's the code attached to the "down" field: if e.down then begin e.|down at| := TimeInSeconds(); e.|up at| := 0; cmt := "down at" && DateNTime(time()) end else begin e.|up at| := TimeInSeconds(); cmt := "up at" && DateNTime(time()); e.|most recent| := e.|up at|-e.|down at|; e.cummulative := e.cummulative + e.|most recent| end; if not e.log or StrLen(e.log) = 0 then e.log := cmt else e.log := e.log & chr(13) & cmt; To record the seconds in the log one could change the cmt assignments to something like: cmt := "down at" && DateNTime(time()) && (e.|down at| mod 60) One note on the use of this database: because of the somewhat annoying requirement in version 1 of Leverage to tap the "down" field three times to change its state (once to open it, once to toggle its value, and once to close it and trigger the code), this database is actually easier to use in list mode. Use the downtime view already defined and just tap in the down column to change the state of a unit, including doing all the calculations, of course. Just to prove that nothing is perfect, this has a small drawback as well. Because Leverage isn't smart enough to tell that the fields changed by the code don't change the order of the display, it redraws the entire list screen when the down field is changed. The unfortunate part is that it places the changed record at the top of the screen -- annoying if you next want to change something that a moment ago was just above it. This is no longer an issue with Leverage version 1.5 since boolean fields are changed with a single tap.