Usage of 'onTimer'

Started by Peter2, December 09, 2014, 03:27:21 AM

Previous topic - Next topic

Peter2

I looked at the help and the sample of "onTimer" and I'm not sure if I understood it entirely ...

The current sample seem to me like a "delay / pause" command: "start something - pause it - continue it".

I don't understand how to define a timer which is "independent" from a command (sorry for my unprofessional wording). Simple example - create a "race of line-drawing", based on a count-down of 10 seconds:

Code (autolisp) Select

start timer for 10 seconds (countdown)
while timer is running
       draw as many lines as you are able to

if timer is down to 0
     alert "Game over"

Maybe I misunderstand the basic target of a timer, but is it possible to make a code like this?
Peter
ODCL 8.1.... German, AutoCAD 2017 - 2018, Win 7 x64, Win 10

owenwengerd

What you describe is not a suitable use for OnTimer. For your scenario, you would simply check the system clock before starting the loop, then check the system clock inside the loop and break out when the clock reaches a certain time. OnTimer is for triggering an event in the future, while normal system activity continues in the meantime.
Owen Wengerd (Outside The Box) / ManuSoft