Oleg to the rescue:
require 'task strings'
deprompt =: (LF;~LF,3{.'' '') rplc ]
capturerun =: ' deprompt ''jconsole'' shell~ y , ''exit 0'' '
t=: 0 : 0
i.10
]a=.+/ i.10
10*a
)
r =: capturerun t
r
0 1 2 3 4 5 6 7 8 9
45
450
Note:
(A) The scheme is to spawn an independent instance of
J (console). Therefore:
(i) The child will not see the results of any lines run in the
parent before its execution (in particular, it cannot see
names defined by the parent), and vice versa after its
execution.
(ii) In short: your script must be stand alone,
and all the interesting results must be produced
as formatted output in the session.
(B) The noun r is the __formatted session output__ of your
script, not the "actual results". That's a big difference.
Formatted output is ambiguous ( 2 -:&": '2' ), subject to
truncation, includes lines that produce but don't assign verbs,
but doesn't include lines that produce and assign nouns, etc,
etc, etc.
These issues are addressable, depending on how much work you want to do.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm