In terms of following the example, the definitions can be pasted to a temp file.
the lines starting with a =. 'smoutput (> 18!:5 '''') ,'': '', ": (6!:0)' new_timer_ 5000 are meant to be run from the console, and test the class. additionally, you can do (from base or other locale): coinsert 'timer' timerexample_base_ =: 3 : 'smoutput@:<''d'';(6!:0) ''''' c =. new 4000 stop'' NB. qualifying with locale becomes optional bc of coinsert resume__c 3000 stop__c'' kill__c'' The class is Joe's code, but made to be more useable (less lines/parameters to write, with really needing to read/understand the class). Defining the timerexample verb (can easily just be called timer) inside a locale that coinsert's the class provides access to all data inside the locale, and so naturally would be a core part of that locale. For a form, you just need to paste in the stop, kill and resume definitions. ----- Original Message ----- From: bill lam <[email protected]> To: 'Pascal Jasmin' via Beta <[email protected]> Cc: Sent: Saturday, May 31, 2014 10:27:45 AM Subject: Re: [Jbeta] [Jprogramming] opportunity to show off jhs or qt I disagree. It would be written differently if intended to run multiple instances. I have difficulty to follow your timer example, in contrast, Joe's is more readable to me. ymmv. Сб, 31 май 2014, JBeta написал(а): > There is a bug in the shader demo. When you launch 2 instances only the > window with mousefocus gets timer events. > > > Thanks to Joe, here is a class that allows "formless timers". It can be > coinserted into another locale (renaming new if name conflict). kill works > without needing stop. the stop,resume,kill verbs can be copied into a " real > form" locale, as long as it holds/sets a form variable, and probably provide > more reliable way to stop/resume timers from multiple form instances. > > cocurrent 'timer' > create =: 3 : 0 > form=: 'a', (> 18!:5 '') > wd 'pc ' , form > resume y > > ) > stop =: 3 : 0 > > wd 'psel ' , form > wd 'ptimer 0' > ) > resume =: 3 : 0 > wd 'psel ' , form > wd 'ptimer ', ": y > ) > kill =: 3 : 0 > wd 'psel ' , form > wd 'pclose' > codestroy '' > ) > timerexample =: 3 : 'smoutput (> 18!:5 '''') ,'': '', ": (6!:0) ''''' > loc_z_=: (,&'_'@[ ,&'_'@, ":@>@])"1 0 > > new =: 3 : 0 > '' new y > : > o =. y conew (> 18!:5 '') > if. 0=#x do. x =.'timerexample' loc o end. > ('a', (> o), '_timer__o') =: 3 : (x , ' ''''') > o > ) > > a =. 'smoutput (> 18!:5 '''') ,'': '', ": (6!:0)' new_timer_ 5000 > b =. new_timer_ 6000 NB. uses locale's timerexample > (overridable) as callback > > > kill__a '' > stop__b '' > resume__b 3000 > kill__b '' > ________________________________ > From: Joe Bogner <[email protected]> > To: Pascal Jasmin <[email protected]> > Cc: "[email protected]" <[email protected]> > Sent: Saturday, May 31, 2014 5:46:51 AM > Subject: Re: [Jprogramming] opportunity to show off jhs or qt > > > > You can use 'wd psel' to set the current form instance which is then used by > 'wd ptimer 0' > > NB. run two timers > NB. works on j802 beta from 5/28 > wd 'pc c' > wd 'ptimer 1000' > > c_timer =: 3 : 'smoutput@:<''c'';(6!:0) ''''' > > wd 'pc d' > wd 'ptimer 1000' > > d_timer =: 3 : 'smoutput@:<''d'';(6!:0) ''''' > > wd 'psel c' > > wd 'ptimer 0' NB. stop c > > wd 'psel d' > > wd 'ptimer 0' NB. stop d > > wd 'psel c' > wd 'ptimer 1000' NB. resume c > > > determined from source: > http://www.jsoftware.com/download/j802/qtide/jqt-source.tar.gz > > A tip I used while testing is to use f8 to paste from keyboard. This keeps > the output from interfering with the input > > > > > > On Sat, May 31, 2014 at 12:26 AM, Pascal Jasmin <[email protected]> > wrote: > > > > > >skipping the pshow command, > > > >I can get both of your timers to run, but can only get one of them to stop. > >It appears as though > >wd 'ptimer xx' affects the most recent wd 'pc X' command, so for instance, > >this sequence of commands: > > > > > >c_timer =: 3 : 'smoutput@:<''c'';(6!:0) ''''' > > > >d_timer =: 3 : 'smoutput@:<''d'';(6!:0) ''''' > > wd 'pc c' > >wd 'ptimer 6000' > >NB. runs as expected > > wd 'ptimer 0' NB. stops as expected. > > wd 'pc d' > >wd 'ptimer 6000' NB. runs only d > > wd 'pc c' > >NB. still runs only d > >wd 'ptimer 6000' NB. will run both on independent timers > > > >wd 'timer 0' NB.only stops C > > wd 'pc d' > >wd 'timer 0' NB. still d won't stop. > > > >erase 'd_timer' NB. stops d > > > >using pshow and pclose doesn't change the result. > > > >it turns out that I can get my object instance timers to also run, but have > >the same problems stopping them... except its worse due to difficulty > >setting timer off. > > > >a =. 6000 conew't' > >b =. 7000 conew't' > >runs both ok. > >stop__a '' NB. stops b... the last pc command. > >kill__b '' NB. runs ok apparently. But does not stop a timer > > > >cannot run stop__a '' or kill__a '' effectively. erase 'a' does nothing. > >Quitting J is easiest, even this direct command fails > > > > kill_0_'' > >|pclose : no parent selected: wd > > > >though this works: (where 0 is first locale...one part of smoutput) > > erase 'a0_timer_0_' > > > >_________________________ > >From: Joe Bogner <[email protected]> > >To: Pascal J <[email protected]> > >Sent: Friday, May 30, 2014 11:20:26 PM > > > >Subject: Re: [Jprogramming] opportunity to show off jhs or qt > > > > > > > >[off list] > > > >Hey Pascal, did you try the code that I posted with multiple timers? That > >worked for me... I didn't run yours but perhaps it's something with the > >locales... Just wanted to check first to see if you were successful with a > >more basic implementation of multiple timers > > > > > > > > > > > >On Fri, May 30, 2014 at 11:00 PM, 'Pascal Jasmin' via Programming > ><[email protected]> wrote: > > > >thank you Bill and Joe, with new version it works. Also wd 'pshow' is not > >necessary. > >> > >>multiple timers may not work though. > >> > >>cocurrent 't' > >>create =: 3 : 0 > >>('a', (> 18!:5 ''), '_timer') =: 3 : 'smoutput (> 18!:5 '''') ,'': '', ": > >>(6!:0) ''''' > >>wd 'pc ' , 'a', (> 18!:5 '') > >>resume y > >>) > >>NB. a_timer =: 3 : 'smoutput (> 18!:5 '''') ,'': '', ": (6!:0) ''''' > >>stop =: 3 : 0 > >>wd 'ptimer 0' > >>) > >>resume =: 3 : 0 > >>wd 'ptimer ', ": y > >>) > >>kill =: 3 : 0 > >>wd 'pclose' > >>codestroy '' > >>) > >> > >> a =. 4000 conew 't' NB. will start timer > >> > >>stop__a '' NB. will stop timer > >> > >> a > >>┌─┐ > >>│1│ > >>└─┘ > >> > >> ] b =. 4000 conew 't' NB. will start new timer ... replacing old. > >>┌─┐ > >>│2│ > >>└─┘ > >> NB. you will see that only timer from b runs. resume__a 2000 will run > >>the timer from b. This error will repeat if you create a 3rd instance. > >>Only timer from last instance runs, even though they all have different > >>"forms" a1 and a2. stop__a '' will stop the timer even if only b is > >>running. > >> > >> a1_timer__a '' NB. a1 comes from using the locale number for variable a > >>1: 2014 5 30 22 28 48.138 > >> > >> a2_timer__b '' NB. a2 comes from using the locale number for variable b > >>2: 2014 5 30 22 29 17.594 > >> > >>If you kill either a or b, then resume__a 3000 will fail, as both "forms" > >>are killed. > >> > >> resume__a 3000 > >>|ptimer : no parent selected: wd > >> > >> > >>Perhaps this is related to my poor understanding of how to run multiple > >>copies of a form? > >> > >> > >> > >>----- Original Message ----- > >>From: Joe Bogner <[email protected]> > >>To: [email protected] > >>Cc: > >> > >>Sent: Friday, May 30, 2014 9:21:00 PM > >>Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >> > >>Pascal, you need to update to the latest. > >> > >>Engine: j701/2011-01-10/11:25 > >> > >>Library: 8.02.06 > >> > >>Qt IDE: 1.1.2/5.3.0 > >> > >>Platform: Win 32 > >> > >>Installer: J802 install > >> > >>InstallPath: c:/users/joe/j802 > >> > >> > >> > >>This works on the latest > >> > >> > >>NB. run two timers > >> > >>NB. works on j802 beta from 5/28 > >> > >>wd 'pc c' > >> > >>wd 'pshow' NB. shows empty form > >> > >>wd :: empty 'ptimer 1000' > >> > >> > >>c_timer =: 3 : 'smoutput@:<''c'';(6!:0) ''''' > >> > >> > >>wd 'pc d' > >> > >>wd 'pshow' NB. shows empty form > >> > >>wd :: empty 'ptimer 1000' > >> > >> > >>d_timer =: 3 : 'smoutput@:<''d'';(6!:0) ''''' > >> > >> > >> > >>This worked on the previous > >> > >> > >> > >>NB. worked previous j802 beta > >> > >>wd 'pc a' > >> > >>wd 'cc g opengl version 2.0 flush' > >> > >>wd 'pshow' NB. shows empty form > >> > >>wd 'set g timer 1000' > >> > >>a_g_timer =: 3 : 'smoutput@:<''a'';(6!:0) ''''' > >> > >> > >>wd 'pc b' > >> > >>wd 'cc g opengl version 2.0 flush' > >> > >>wd 'pshow' NB. shows empty form > >> > >>wd 'set g timer 1000' > >> > >>b_g_timer =: 3 : 'smoutput@:<''b'';(6!:0) ''''' > >> > >> > >> > >> > >>I was stuck on it too > >> > >> > >> > >>On Fri, May 30, 2014 at 9:12 PM, 'Pascal Jasmin' via Programming < > >>[email protected]> wrote: > >> > >>> Engine: j701/2011-01-10/11:25 > >>> Library: 8.02.06 > >>> Qt IDE: 1.1.1/5.3.0 > >>> Platform: Win 64 > >>> > >>> > >>> ----- Original Message ----- > >>> From: bill lam <[email protected]> > >>> To: "[email protected]" <[email protected]> > >>> Cc: > >>> Sent: Friday, May 30, 2014 8:12:21 PM > >>> Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >>> > >>> what is your JVERSION ? > >>> > >>> 31.05.2014, в 8:03, "'Pascal Jasmin' via Programming" < > >>> [email protected]> написал(а): > >>> > >>> > the shader demo works. cube rotates, etc... > >>> > > >>> > when I try those 3 lines from the base locale (jqt802 console session), > >>> the error shown occurs. > >>> > > >>> > > >>> > ----- Original Message ----- > >>> > From: bill lam <[email protected]> > >>> > To: "[email protected]" <[email protected]> > >>> > Cc: > >>> > Sent: Friday, May 30, 2014 8:00:24 PM > >>> > Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >>> > > >>> > did the cube rotate? did you test on the latest j802/jqt beta? > >>> > > >>> > 31.05.2014, в 7:48, "'Pascal Jasmin' via Programming" < > >>> [email protected]> написал(а): > >>> > > >>> >> from base, > >>> >> > >>> >> wd 'pc a;' NB. or 'pc a' > >>> >> wd 'pshow' NB. shows empty form > >>> >> wd 'ptimer 2000' > >>> >> |ptimer : parent command not found: ptimer: wd > >>> >> > >>> >> > >>> >> a_timer_base_ > >>> >> 3 : 'smoutput@:(6!:0) ''''' > >>> >> > >>> >> is this something related to base locale? > >>> >> > >>> >> shader demo works ok. > >>> >> > >>> >> > >>> >> ----- Original Message ----- > >>> >> From: bill lam <[email protected]> > >>> >> To: "[email protected]" <[email protected]> > >>> >> Cc: > >>> >> Sent: Friday, May 30, 2014 6:40:53 PM > >>> >> Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >>> >> > >>> >> You didn't even create a form. To recap, a form is created using wd cmd > >>> eg > >>> >> > >>> >> wd'pc foo' > >>> >> > >>> >> the locale of a form is the current locale when that wd'pc foo' is > >>> executed. > >>> >> > >>> >> 31.05.2014, в 0:49, "'Pascal Jasmin' via Programming" < > >>> [email protected]> написал(а): > >>> >> > >>> >>> sorry for previous message, was running timer and not ptimer. > >>> >>> > >>> >>> It does not appear as though you can get a timer into an arbitrary > >>> locale by just doing wd 'pc a' there. The form has to be visible, or > >>> needs > >>> an initial show? > >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>> ----- Original Message ----- > >>> >>> From: 'Pascal Jasmin' via Programming <[email protected]> > >>> >>> To: "[email protected]" <[email protected]> > >>> >>> Cc: > >>> >>> Sent: Friday, May 30, 2014 12:23:37 PM > >>> >>> Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >>> >>> > >>> >>> Nice, thank you. > >>> >>> > >>> >>> You can also use a timer in any arbitrary locale (I think) > >>> >>> > >>> >>> a_timer_ =: show_base_ > >>> >>> wd_a_ 'timer 2000' > >>> >>> > >>> >>> or > >>> >>> > >>> >>> aa =. conew 'a' > >>> >>> wd__aa 'timer 2000' > >>> >>> > >>> >>> acts a little weird with just one plot window, but that might be plot > >>> related? > >>> >>> > >>> >>> > >>> >>> ----- Original Message ----- > >>> >>> From: bill lam <[email protected]> > >>> >>> To: 'Pascal Jasmin' via Programming <[email protected]> > >>> >>> Cc: > >>> >>> Sent: Friday, May 30, 2014 11:19:17 AM > >>> >>> Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >>> >>> > >>> >>> Oh sorry! I thought ptimer was documented but not yet. Basically > >>> >>> it is very simple, if your form id is 'foo' then the name of the > >>> >>> timer callback verb is 'foo_timer' in the form's locale. Each form > >>> >>> has its own timer. wd'ptimer xx' will start or stop timer attached > >>> >>> to the current form. Unlike the old wd timer, form timers will not > >>> >>> break existing code. In qt shader demo, the cube is rotated by a > >>> >>> form timer. > >>> >>> > >>> >>> Пт, 30 май 2014, jprogramming написал(а): > >>> >>>> good news about wd 'timer' for forms. A wishlist would include a way > >>> for minimal library load for jconsole support. > >>> >>>> > >>> >>>> I don't see it mentioned here though > >>> http://www.jsoftware.com/jwiki/System/ReleaseNotes/J802 > >>> >>>> > >>> >>>> I did see that the timer qt demo app has been updated, but its hard > >>> to understand without a "qtdemo form" > >>> >>>> > >>> >>>> there is no mention of wd 'ptimer' here: > >>> http://www.jsoftware.com/jwiki/Guides/Window%20Driver/Command%20Reference > >>> >>>> > >>> >>>> > >>> >>>> ----- Original Message ----- > >>> >>>> From: bill lam <[email protected]> > >>> >>>> To: [email protected] > >>> >>>> Cc: > >>> >>>> Sent: Friday, May 30, 2014 10:08:14 AM > >>> >>>> Subject: Re: [Jprogramming] opportunity to show off jhs or qt > >>> >>>> > >>> >>>> sleep will halt current thread, not a feature of jqt. One can > >>> >>>> use wd'timer' to fire event. Furthermore J802 introduce form timer > >>> >>>> for each form, see high-lights. > >>> >>>> > >>> >>>> Пт, 30 май 2014, Raul Miller написал(а): > >>> >>>>> I made the hour hand be a 24 hour hour-hand. To make it the more > >>> typical 12 > >>> >>>>> hour hour-hand, change 2r24p1 2r60p1 2r60p1 to 2r12p1 2r60p1 2r60p1. > >>> >>>>> > >>> >>>>> And the window freezing issue is a "feature" of jqt. To avoid that > >>> issue > >>> >>>>> with current versions of jqt, always close (or position) the plot > >>> window > >>> >>>>> before starting the clock. > >>> >>>>> > >>> >>>>> Thanks, > >>> >>>>> > >>> >>>>> -- > >>> >>>>> Raul > >>> >>>>> > >>> >>>>> > >>> >>>>> > >>> >>>>> On Fri, May 30, 2014 at 4:43 AM, Jan-Pieter Jacobs < > >>> >>>>> [email protected]> wrote: > >>> >>>>> > >>> >>>>>> Nice! > >>> >>>>>> I tried your code in JQT (on windows 8), some remarks: > >>> >>>>>> > >>> >>>>>> The hour hand is pointing about the exact oposite direction it > >>> should. > >>> >>>>>> Somehow, switching windows also causes the plot window to freeze, > >>> and J to > >>> >>>>>> become unresponsive > >>> >>>>>> > >>> >>>>>> > >>> >>>>>> Jan-Pieter > >>> >>>>>> > >>> >>>>>> > >>> >>>>>> 2014-05-30 3:18 GMT+02:00 Raul Miller <[email protected]>: > >>> >>>>>> > >>> >>>>>>> Here's another approach (beware of email induced line wrap in > >>> definition > >>> >>>>>> of > >>> >>>>>>> show): > >>> >>>>>>> > >>> >>>>>>> N=:0.01*i.629 > >>> >>>>>>> O=: [: j./ 1 2 o./ ] > >>> >>>>>>> delay=:6!:3 NB. "sleep" > >>> >>>>>>> > >>> >>>>>>> show=: [: plot (O N),N*/~0.07 0.11 0.15(*O) 2r24p1 2r60p1 > >>> 2r60p1*_3{.6!:0 > >>> >>>>>>> bind '' > >>> >>>>>>> > >>> >>>>>>> show@delay@1:^:9e9'' > >>> >>>>>>> > >>> >>>>>>> I think this should work with both jqt and the j602 ide. > >>> >>>>>>> > >>> >>>>>>> Thanks, > >>> >>>>>>> > >>> >>>>>>> -- > >>> >>>>>>> Raul > >>> >>>>>>> > >>> >>>>>>> > >>> >>>>>>> > >>> >>>>>>> On Thu, May 29, 2014 at 1:39 PM, David Lambert < > >>> [email protected]> > >>> >>>>>>> wrote: > >>> >>>>>>> > >>> >>>>>>>> http://rosettacode.org/wiki/Draw_a_clock#J > >>> >>>>>>>> > >>> >>>>>>>> The next author need only replace the draw dyad, or rewrite the > >>> >>>>>>>> contribution. > >>> >>>>>>>> x is the current session time, y is the session time when the > >>> >>>>>>>> verb > >>> >>>>>>> starts. > >>> >>>>>>>> > >>> >>>>>>>> round=: [: <. 0.5&+ > >>> >>>>>>>> PICTURES=: u:16b2190+i.4 NB. arrows > >>> >>>>>>>> draw=: [: smoutput PICTURES ((|~ #)~ { [) [: round - > >>> >>>>>>>> > >>> >>>>>>>> > >>> ---------------------------------------------------------------------- > >>> >>>>>>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>> >>>>>>>> > >>> >>>>>>> > >>> ---------------------------------------------------------------------- > >>> >>>>>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>> >>>>>>> > >>> >>>>>> > >>> ---------------------------------------------------------------------- > >>> >>>>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>> >>>>>> > >>> >>>>> > >>> ---------------------------------------------------------------------- > >>> >>>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>> >>>> > >>> >>>> -- > >>> >>>> regards, > >>> >>>> ==================================================== > >>> >>>> GPG key 1024D/4434BAB3 2008-08-24 > >>> >>>> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 > >>> >>>> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 > >> > >> > >> > >>> > >>> > >>> > >>> > > >>> > > >>> > > >>> >> > >>> >> > >>> >> > >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>> > >>> >>>> > >>> >>>> > >>> >>>> > >>> >>>> ---------------------------------------------------------------------- > >>> >>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>> >>>> ---------------------------------------------------------------------- > >>> >>>> For information about J forums see > >>> http://www.jsoftware.com/forums.htm > >>> >>> > >>> >>> -- > >>> >>> regards, > >>> >>> ==================================================== > >>> >>> GPG key 1024D/4434BAB3 2008-08-24 > >>> >>> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 > >>> >>> gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 > >>> >>> ---------------------------------------------------------------------- > >>> >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> >>> ---------------------------------------------------------------------- > >>> >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> >>> ---------------------------------------------------------------------- > >>> >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> >> ---------------------------------------------------------------------- > >>> >> For information about J forums see http://www.jsoftware.com/forums.htm > >>> >> ---------------------------------------------------------------------- > >>> >> For information about J forums see http://www.jsoftware.com/forums.htm > >>> > ---------------------------------------------------------------------- > >>> > For information about J forums see http://www.jsoftware.com/forums.htm > >>> > ---------------------------------------------------------------------- > >>> > For information about J forums see http://www.jsoftware.com/forums.htm > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > >>> > >>---------------------------------------------------------------------- > >>For information about J forums see http://www.jsoftware.com/forums.htm > >>---------------------------------------------------------------------- > >>For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
