Try

sys_timer =: {{
try.
  smoutput 'tick'
catch.
  wd 'timer 0'
  smoutput 'error in timer'
  smoutput (<: 13!:11'') {:: 9!:8''
  smoutput 13!:12''
end.
i. 0 0
}}
sys_timer_z_ =: sys_timer_base_

You always want a try./catch. in the timer to keep you from getting the same error repeatedly.

Henry Rich

On 1/2/2021 6:53 PM, cilz wrote:
As a first attempt here what I did :

sys_timer_z_ =: (echo 'hello')

wd 'timer 5000'

but I get only one "hello" and nothing more.

And it didn't work at all with my own function!

Did I do anything wrong ?

Best, Eric


Le 03/01/2021 à 00:16, Raul Miller a écrit :
Ah, yes... the systimer event handler is the only way to go here.

Basically,

1) you implement the body of your loop as a monadic verb which ignores
its y argument. Let's call that verb xyzzy.

2a) You define sys_timer_z_=: xyzzy

2b) You decide on a polling interval -- lets say 1234 milliseconds,
and you set it to running using the wd timer mechanism: wd 'timer
1234' (You'll want to use a shorter interval once you're confident
that things work right. But it's probably good to start slow.)

https://code.jsoftware.com/wiki/Guides/Window_Driver/Event_Handling
https://code.jsoftware.com/wiki/Guides/Window_Driver/Command_Reference

Note that debugging this can be interesting, because of how errors
will interfere with what you are trying to do to debug it. So the
first time you run into a problem you'll probably have to shut down J
(make sure your work is saved in scripts), and then after that you'll
probably want to start working with techniques for regaining control
and/or extracting useful information to isolate the errors. (Not
complicated / still needs experience and understanding.)

But this should at least get you started.

Good luck,

-- Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


--
This email has been checked for viruses by AVG.
https://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to