Brian Schott wrote:
>       I would prefer an existing solution, but can
> explorethe queue idea, too. But getting the user's inputs
> in the ijx window into a queue does not seem like something
> I want to do because I want the user to be able to type
> commands and verb definitions of their own into the ijx
> window. Commands and verbs that use allowed turtle
> instructions like "forward 1" and "right 90", where forward
> and right are defined verbs in my system. So if go =: 3
> : 'forward 1' then "go[go[go''" would mean go forward 3
> steps in three separate increments. I don't want to have to
> parse "go[go[go''" into three queue items; that's J's job,
> isn't it?

I don't know what you mean by "J's job".

It seems to me that you write the definitions for words like
"forward" and "right".  You can write these words so that
they queue instructions for the timer event handler.

Perhaps this is as simple as

QUEUE=:0 2$0
forward=:monad define
 forwardNow enqueue y
)

right=:monad define
 rightNow enqueue y
)

enqueue=:conjunction define
 QUEUE=:QUEUE,(5!:1 <'x'),&<(5!:1<'y')
 ,.''
)

dequeue=:monad define
 if.#QUEUE do.
  'x y'=.{.QUEUE
  QUEUE=:}.QUEUE
  ".'(x 5!:0)(y 5!:0)'
 end.
)

You would need to supply definitions for forwardNow
and rightNow, and you would need to supply a timer
event handler, but you've already done the hard part
of that.

-- 
Raul

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

Reply via email to