Doevents is mainly intended for single-thread applications. For multi-threading application, it is less important.
In single thread event driven applications, msgs/doevents can jump to process any events. Eg, msgs inside a tight loop can interrupt and abort if users press the close button. That said, msgs is useful since J is single threaded and so it is implemented in J wd. Пт, 16 дек 2016, Raul Miller написал(а): > Why do you claim wd'msgs' is bad practice in J? > > The only reasoning I can find would imply that use of J is bad > practice, and I refuse to agree with that kind of thinking. > > (More specifically, the criticisms of "doevents" which I find seem to > be aimed at using fine grained multi-threading and flow of control. > But that makes it sound using wd'msgs' would be *good practice* in the > context of J. Still, perhaps I have overlooked something?) > > Thanks, > > -- > Raul > > > On Fri, Dec 16, 2016 at 8:12 PM, bill lam <[email protected]> wrote: > > wd'msgs' is the equivalent of doevents() in visual basic and dotnet > > winform. It is a bad practice and can cause unpredictable behaviors. > > Android does not support it. Try other alternatives first. > > > > That said, using it in Michael's context should be ok. Writing to file as > > suggested by Eric is a more general solution. > > > > > > On 17 Dec, 2016 6:07 am, "'Pascal Jasmin' via Programming" < > > [email protected]> wrote: > > > > a slightly different version of echo (that returns argument instead of i.0 > > 0) > > > > pD =: (1!:2&2)`(wd bind 'msgs' ] 1!:2&2)@.IFQT > > echo =: (0 0 $1!:2&2)`(wd bind 'msgs' ] 0 0 $ 1!:2&2)@.IFQT > > > > works "universally" > > > > 3 : 'i =. 0 while. i < y do. if. 0 = 1000000 | i do. pD i end. i =. i+1 > > end.' 10000000 > > > > > > ----- Original Message ----- > > From: Eric Iverson <[email protected]> > > To: Programming forum <[email protected]> > > Sent: Friday, December 16, 2016 4:40 PM > > Subject: Re: [Jprogramming] How can I echo characters to JQT terminal > > window each time through a loop? > > > > This is a perennial problem. Jconsole and JHS will show echo output before > > execution completes, but Jqt won't. There may be Jqt mechanisms, such as > > other windows, and special wd commands that would work. In my experience > > the best general solution to this problem is to have the loop where you > > currently have the echo, do an fwrite or fappend of status information to a > > file. Then, while the big update is running, a completely separate task can > > inspect the file contents. This is easy to do, works on all front ends, > > works on all platforms, and supports logging info that wouldn't easily fit > > into echo. In your case just replace the echos with an appropriate fwrite > > of formated data. > > > > On Fri, Dec 16, 2016 at 3:22 PM, Michael Berry <[email protected]> wrote: > > > >> I am looping through a large database table 1,000 rows at a time and I > >> would like to show some reassuring output. I tried echo and smoutput (are > >> these different?) but both sat there until the whole explicit definition > >> ended and then printed out the progress notes all at once. Do I need some > >> sort of flush output command? > >> > >> Here is the loop I tried: > >> > >> while. 0 = _1 -: d=. ddfch sh, 1000 NB. ddfet fails unpredictably so use > >> ddfch instead > >> > >> do. > >> > >> data=. make_cells d NB. put into ddfet format as expected by run_tests > >> > >> scores=. run_tests data > >> > >> r=. make_cols data,. <"1 scores > >> > >> assert. 0 = ch2 ddins~ ('select * from ',y,'_scored where 0=1');r > >> > >> echo written=. written + 1{. $data > >> > >> end. > >> ---------------------------------------------------------------------- > >> 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
