> Is there a good, or  any, way to set this variable while the loop is
running?

Not in the same process; J is single threaded.  That means, while it's
chewing on your data, it cannot process any other events.  That includes GUI
events.  That's why you get the "boink":  Windows is telling you J is too
busy to handle your request.

One small exception to this rule is jbreak (is that what you're referring to
with "methods from the operating system"?).  In any event, jbreak is the
yellow J icon in your J program group.  You might want to drag this to your
quick launch toolbar, so it's easy to press when you need to.   You may also
drag a copy to your desktop, right-click on it, and assign it a shortcut
key.  Then, when you want to interrupt J, just hit the keystroke.

Though short, the Usr guide has some information on interrupting J and on
J's message pump:

http://www.jsoftware.com/help/user/interrupt.htm
http://www.jsoftware.com/help/user/message_pump.htm

The links are worth reading. In particular, message_pump will tell you that
if you hit jbreak once, then the break will occur right before the next
sentence is executed, but if you hit it twice, jbreak can stop J in the
middle of a sentence, with unpredictable results.

Having said all that, the answer to your question is yes.  You can set the
the variable while the loop is running.   You just can't do it in the same
process.

The J system comes with a feature called "mapped files", and it allows
(among other things) J processes to share variables.  When a mapped noun is
changed in one J process, it is automatically and immediately changed in all
other J processes sharing that variable.  So you could have a separate J
process, with a little GUI, that just set a variable when a button was
pressed.  The next time your looping process checked the variable, it would
see the new value.

I tried to mock up a demo for you, but it seems shared variables are broken
in the beta I'm using.  I'll update to a newer beta and see if it's fixed
there.  Meanwhile you might go through the Lab "mapped files"; it provides
more details on JMF, and will show you how to map and share variables.

-Dan
-- 
View this message in context: 
http://www.nabble.com/Soft-stopping-of-a-long-loop-tp14841153s24193p14842680.html
Sent from the J Programming mailing list archive at Nabble.com.

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

Reply via email to