var onoff : int := 0 var oldmx, oldmy : int if mb = 1 and current_tool = "pen" and onoff = 0 then onoff := 1 drawdot (mx, my, col) oldmx := mx oldmy := my elsif mb = 1 and current_tool = "pen" and onoff = 1 then drawline (oldmx, oldmy, mx, my, col) oldmx := mx oldmy := my drawdot (mx, my, col) elsif mb = 0 and current_tool = "pen" and onoff = 1 then onoff := 0 end if