Yuva asked:
> This is like editing a .ijs file, invoking CTRL-w, and continuing with the
> execution using the latest definitions from J execution window.
> What is the J Code for this?
The question is a bit unclear. Fundamentally, 0!: executes scripts. In
practice, we mostly use the cover verb load_z_ . But I suspect you know that
already. Could you describe what you want in more detail?
First off, why do you want to reload a script? Are you programmatically
re-writing its contents? Do you want to re-execute it to reset state (i.e.
reassign globals to the default)?
If the latter, then I guess your question is "How do I reload the current
script?". The answer to that is still load , but it requires you know the
name of the current script. That, you can discover with 4!:3 and 4!:4 .
For example, 3 : 'load (4!:4<''y'') { 4!:3$0' 0 will reload whatever script
it's run from (it won't work in the IJX window). More specifically, if you had
a form named matrix with a button named reloaded then you could define a
verb in your form script:
matrix_reloaded_button =: 3 : 'load (4!:4<''y'') { 4!:3$0'
then, when the user pressed your reload button, it would reload your form
script.
If the former, i.e. that you're programmatically re-writing a script, then you
already know its name, and this won't help you; you have some other question.
If that's the case, the best I can do is tell you how CTRL+W works (or, how to
find out how it works). Run open'jijs' . That script is responsible for all
the script-editing features of the session manager. In particular, you'll want
to look at:
jijs_wctrl_fkey_jijs_
which is defined as:
jijs_runwindow_button_jijs_
which calls:
runwindow_jijs_
which fundamentally calls:
load SMNAME_x_
where x is the (numbered) locale of the script window where you pressed
CTRL+W. There's a bit of indirection here, with 9!:27 (which runs the load
sentence when the session returns to immex), but I don't think that's relevant
to your question.
Or maybe it is. Are you asking how to reload a script once the current process
(verb) completes execution? That is, you want to do some work, then reload the
script after you're done (i.e. the stack is empty and J is back in an "idle"
state)? If so, 9!:27 (with 9!:29 ) is the answer. Have a look at
runimmx1_jijs_ .
I hope this helped. If not, could you describe what you want in a little more
detail, or post some code?
-Dan
PS: In practice, the only time I've wanted to reload a script was in a
production J server. I had an order management system that couldn't go down
while the market was open. So, when a trader discovered a bug in production,
I'd edit the relevant scripts and simply walk over the production machine and
type load foo into the session manager, where foo were the scripts I
changed. The nice thing was, this worked, even when I had a bug in the
socket-handling script itself!
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm