Testing the ticker code from the doc work so far, but trying to reset it as desribed crashes newLISP:
> (define (ticker)(println (date)) (timer 'ticker 10.0))
(lambda () (println (date)) (timer 'ticker 10))
> (ticker)
Tue Sep 05 22:52:04 2006
10
> Tue Sep 05 22:52:14 2006
> Tue Sep 05 22:52:24 2006
> (define (ticker)(println (date)) (timer 'ticker 0.0))
(lambda () (println (date)) (timer 'ticker 0))
> (ticker)
Tue Sep 05 22:52:31 2006
0
> Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
Tue Sep 05 22:52:31 2006
I tested with newLISP-tk and the DLL version.
You cannot change a function while it is running. That will always crash.
To stop the ticker you could set some global variable for the ticker time and then change that variable to a different value, or some similar scheme.
Lutz
I tried the follwoing but I still gets the crash:
newLISP v.8.9.8 on Win32 MinGW.
> (setq MyTime 10.0)
10
> (define (ticker)(println (date)) (timer 'ticker MyTime))
(lambda () (println (date)) (timer 'ticker MyTime))
> (ticker)
Wed Sep 06 07:37:04 2006
10
> Wed Sep 06 07:37:14 2006
> Wed Sep 06 07:37:24 2006
> (setq MyTime 0.0)
0
> Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
Wed Sep 06 07:37:34 2006
....
....
What is wrong?
Seems to get into a endless loop and gets some overflow?
>Seems to get into a endless loop and gets some overflow?
Lutz, any idea here?
Yes, after reviewing the code I realize setting the time to 0.0 only works on UNIX. On Win32 the timer is implemented in a different way using windows thraeds and watching the time in the thread, it is taking the 0.0 as a very short time and goes into a loop.
But I am sure there is a way to implement that feature in Win32 too. Look out for it in the next development version.
Meanwhile you could use this workaround:
(define (ticker)
(println (date))
(if (> MyTime 0.0) (timer 'ticker MyTime)))
Lutz
Quote
But I am sure there is a way to implement that feature in Win32 too. Look out for it in the next development version.
Great! And thanks for the workaround.