@Eric

>  2!:0 'afplay ~/wav/test6s.wav &'

Yes, I've tried that too.

What happens (...and this may only be on the Mac: just now I don't
have a Windows machine to try it) is that the sound starts playing and
the jijx session straightaway prompts for new input.

But if I enter, say, i.6 *whilst the sound is still playing* ... the
letters "i.6" appear ok in the jijx window, but then the session hangs
until the sound stops. Only then does a new line appear with the
result:
0 1 2 3 4 5

Let me emphasise 3 things...

1. The "afplay" command is merely a simple example I've chosen to
illustrate my problem.
What I really want to do is not to play sound at all, but to launch an
asynchronous process with the command:
   java -d32 -Xss8000000 -jar /Applications/j602/bin/j.jar  -jijx
/Users/ianclark/j602-user/loface.ijs &
(...You may wonder why. I'll gladly explain. But right now I guess
it's a distraction.)
This command does work, and does indeed launch loface.ijs ok... and my
J code does actually continue after the 2!:0 statement and runs to
completion.
*But...*
I can't in practice enter anything by hand in the jijx session until I
terminate loface. Whilst loface (or afplay, or whatever) is running,
jijx hangs. Why?

2. For my task-in-hand, this issue is not holding me up any more. I
can launch loface.ijs as an independent self-contained app --and I
don't run into any trouble. It's all working just fine. But I'm
curious to know the answer, because I wonder if the same issue isn't
turning up (for me) in a disguised shape elsewhere.

3. You may have given me the missing piece of my jigsaw by reminding
us that JHS "talks directly to the socket". Hitherto I've been banging
away trying to set up a duty-cycle to watch for data coming in from
loface.ijs (say). But am I not right in thinking that JHS already runs
a continuous loop to talk to the socket? So why don't I hook into that
loop?

On Fri, Feb 17, 2012 at 6:10 PM, Eric Iverson <eric.b.iver...@gmail.com> wrote:
> Haven't read this thread carefully, but at first blush I wonder why you are
> using 2!:1 at all. I think your example would work as you wish with 2!:0.
> That is,
>
>  2!:0 'afplay ~/wav/test6s.wav &'
>
> On Tue, Feb 14, 2012 at 4:04 PM, Ian Clark <earthspo...@gmail.com> wrote:
>
>> 2!:1 is not truly asynchronous in JHS, it seems. The net result is
>> that I cannot see how to launch a child process without the session
>> hanging until the child terminates.
>>
>> Strange to say, the jijx session immediately resumes, and will accept
>> (re-)input. But it will not execute the inputted expression. Inside a
>> verb however, execution continues past 2!:1 (which successfully forks
>> the child process), but after completion of the verb the session is
>> silent (until the child process is terminated).
>>
>> Example:
>> Suppose test6s.wav is a sound file lasting 6 seconds. (Chosen to last
>> long enough to allow "i.6" to be entered.)
>>
>>   2!:1 'afplay ~/wav/test6s.wav &'
>>   i.6
>> 0 1 2 3 4 5
>>
>> The jijx accepts i.6 but hangs until test6s.wav finishes playing. Only
>> then does 0 1 2 3 4 5 appear.
>>
>>   JVERSION
>> Engine: j701/2011-01-10/11:25 build: Feb  6 2011 16:16:29
>> Library: 7.01.055
>> Platform: Darwin 64
>> Installer: j701a_mac64.dmg
>> ----------------------------------------------------------------------
>> 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

Reply via email to