@name Robotboy655's Expression One: Stopwatch
@inputs Start Stop Reset
@outputs Current Lap Record
@persist Time Running

# Increment time for each clock pulse
if(clk()){Time += 0.02
interval(20)}

# Start the clock, also restart
if(~Start & Start){
    if(Running & (Time < Record | !Record)){
        Record = Time}
    Lap = Time
 Time = 0
    Running = 1
interval(20)}

# Stop the clock and update times
if(~Stop & Stop & Running){
    Lap = Time
    if(Time < Record | !Record){
        Record = Time}
    Running = 0
interval(0)}

# Reset all values and stop the clock
if(Reset){
    Time  = Lap = Record = 0
    Running = 0
interval(0)}

Current = Time
