[I am replying to an earlier message because it contains several details to
which I would like to refer.]

My understanding is that there can only be one jhrajax in the server for
any jdoajax() sent by the client. If that is true, my problem is that the
event which should produce the jhrajax is the completion of all processing
by the server, but I don't know how to know programmatically that J
processing is complete.

Let me try to elaborate. Imagine the client entering the following command.
(You can see the conjunction repeats's definition in the message to which I
am replying.)

(3 repeats fd) 10

You know and the server eventually knows that that command unfolds into
three commands that require a paint in j (the server) and a draw() in js
(the client):

fd 10
fd 10
fd 10

As my app is currently written, the server's paint verb ends with a jhrajax
and because each `fd 10` triggers a paint, unchanged, the server replies to
the client after the first 'fd 10` (where 10 is arbitrary and could be any
integer). To avoid this early reply to the client, the jhrajax has to be
triggered only after the third `fd 10` (and after the results of the 3 `fd
10`s have been stored in a suitably constructed "queue" for the reply.

But how do I get the server, j, to be **introspective** and to know when
all the processing -- of `fd 10`s in this example -- is completed?

In step (2) in the replied-to message list, the server receives the request
with ev_command_enter.  The server can be told to empty a noun, say
"queue", upon receiving any command, by adding a line to ev_command_enter
as suggested below. And then each paint's jhrajax command can be changed to
a command which appends to that "queue".

ev_command_enter=: 3 : 0
queue =: i. 0      NB. this is the added
". s=. getv 'command'
)

I think I understand how to initiate the period of introspection, perhaps
in a manner similar to how the queue can be emptied. But how I don't know
how to "introspect" in J. Is there a foreign, or is there a way to use
sysevent to ask J, "are you idle now?"


Thanks, again,




On Sat, Mar 22, 2014 at 11:38 AM, Brian Schott <[email protected]>wrote:

> First the good news. Joe's idea to use alldata.push(row); to '...push the
> single row to a javascript array...' works fine, except that only after
> much head scratching I discovered I needed .concat in addition to .push for
> turtle paths, (not for turtle avatars).
>
> The bad news is pretty devastating. I cannot think of a way to deal with
> user entries in the text field that combine multiple turtle moves/turns.
> Only the first move or turn is reflected in the immediate visible result
> and the system seems to think for an unduly long time.
>
> To explain the issue, I will outline the current processing sequence of
> tgsjhs, the app. ***I can think of no way to cycle repeatedly through
> steps (2) to (5) when there are embedded multiple turtle moves/turns. ***
>
> (0) The user enters  a 'command' which is a turtle move or turn (and if
> not for my problem, other commands with embedded multiple turns or moves).
> A typical single command is `fd 20` to move the turtle(s) forward 20 steps.
>
> (1) That 'command' is sent via js's
> ev_command_enter(){jdoajax(["command"],"");} to jhs.
>
> (2) The command is processed in jhs to produce a new or incumbent turtle
> heading/position vectors and a new or incumbent turtle path.
>
> (3) The produced vectors and paths are sent back to js by paint's jhrajax.
>
> (4) Js receives the vectors and paths in ev_command_enter_ajax(row)
>
> (5) The collected vectors and paths are processed by the drawing js
> function draw(), which populates the canvas using webgl.
>
> (6) The web page awaits more user inputs.
>
> For example, there is a defined conjunction, repeats, as follows. The verb
> v might be `fd` from above in a silly example to repeatedly move fd in
> steps, rather than all at once.
>
> NB. enable one-liner turtle movement sequences
> repeats=: conjunction define
> for. i. m
> do. v y
> end.
> :
> for. i. m
> do. x v y
> end.
> )
>
> Surely this can be done with minimal user knowledge of the problem. But I
> cannot figure out how. Help would be appreciated.
>
> Thank you,
>
>
> --
(B=)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to