Does O2 have anything similar to timer from some other Basics?
TIMER Function
Purpose:
To return single-precision floating-point numbers representing the elapsed number of seconds since midnight or system reset.
Syntax:
v=TIMER
Comments:
Fractions of seconds are calculated to the nearest degree possible. Timer is read-only.
There are some real-time functions in inc\timerutil.inc, which you could adapt