After reading a bit more of you code, I need to change some of the details
of my suggestions.

Immediately above your definition of 'paint' in tgsjhs.ijs you have:

ev_command_enter=: 3 : 0
". s=. getv 'command'
)

At the bottom of your 'paint' definition you have the line:
     jhrajax linecolors,JASEP,lines,temp

What I am proposing is that you store these values (linecolors, lines,
temp) in your tgsj locale. You will have to change things slightly, so that
paint can run multiple times. And then run the modified jhrajax from
ev_command_enter.

Perhaps something like this:

ev_command_enter=:3 :0
  PENDING=:''
  ". s=. getv 'command'
  jhrajax PENDING
)

And then in 'paint' you would append data to PENDING.

Possibly you would need to get a little fancier than that - I've not
studied your code in enough detail to guide this process.

But this would let you run 'paint' as many times as you need, and still get
the "only one jhrajax" that your current design seems to need.

Does this make sense?

Thanks,

-- 
Raul






On Sun, Mar 23, 2014 at 5:49 PM, Brian Schott <[email protected]>wrote:

> Raul,
>
> That demonstration of putting jdoajax(...) into the console was very clever
> and helpful. You may be on to something, but I am not sure because I don't
> quite follow your idea of "override ev_command_enter". Do you understand
> that in my app 'command' is my name of the event of entering a turtle
> command as text into the sole text field in the html document? If you
> already understood that, then maybe you are suggesting something wild like
> embedding that text field in something like a separate **hidden** input
> field (if that even is possible) that is automatically jdoajaxed just
> before or after the 'command' jdoajax, and is somehow able to collect the
> various multiple jhrajaxes from off of the/a stack? That would be quite a
> feat, but I like the idea.
>
>
>
>
>
>
>
> On Sun, Mar 23, 2014 at 4:00 PM, Raul Miller <[email protected]>
> wrote:
>
> > Oops, there's no 'command' argument to jdoajax. I'd have to look a bit
> more
> > to determine where command comes from. Might be easiest to just override
> > ev_command_enter in tgsj. I'm sure there's cleaner ways of approaching
> > this, but I've other things occupying my attention right now so am not
> > inclined to go looking for them.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> > On Sun, Mar 23, 2014 at 3:58 PM, Raul Miller <[email protected]>
> > wrote:
> >
> > > Here's jdoajax:
> > >
> > > function jdoajax(ids,data,sentence,async) {
> > >  if(0!=rqstate) return; // previously - alert("busy - wait for previous
> > > request to finish");
> > >   async= (!async)?false:async;
> > >  sentence=sentence||jevsentence;
> > >  data=data||"";
> > >  ids=ids||[];
> > >  rq= newrq();
> > >  if(async) rq.onreadystatechange= jdor;
> > >  rq.open("POST",jform.jlocale.value,async); // true for async call
> > >  jform.jdo.value= ('undefined'==typeof sentence)?jevsentence:sentence;
> > >  rq.send(jpostargs(ids)+"&jdata="+jencode(data)+"&jwid="+jencode(
> > > window.name));
> > >  if(!async)jdor();
> > > }
> > >
> > > If I open up the javascript console in my jijx window and execute
> > >
> > > jdoajax([],'','i.3')
> > >
> > > I get to see i.3 entered in the jijx window (and its result).
> > >
> > > If I instead do:
> > > jdoajax([],'','i.3');jdoajax([],'','i.4');jdoajax([],'','i.5');
> > >
> > > I get to see all three lines entered and their results displayed.
> > >
> > > That said, if I turn on async:
> > >
> > > jdoajax([],'','i.3',1);jdoajax([],'','i.4',1);jdoajax([],'','i.5',1);
> > >
> > > only the first one gets executed.
> > >
> > > Looking closer, in the first set of three, three http requests are
> posted
> > > to the server. But when I pass the fourth "async" argument, the browser
> > > only makes the first request.
> > >
> > > Meanwhile, looking at your code, I think the problem is that jhrajax
> does
> > > not belong in 'paint'. jhrajax belongs at the top level
> > >
> > > So now the question is "what is the top level"?
> > >
> > > When I look at the stack in place when paint executes for fd 20, it
> looks
> > > like this:
> > >
> > > paint
> > > advance
> > > fd
> > > ev_command_enter
> > > jev_tgsj_
> > >
> > > The bottom two levels are pre-defined, in jhs. You could have fd be the
> > > top level, but then it would not make sense to have other routines call
> > fd.
> > >  (Because, if they did, it would violate our abstraction of considering
> > fd
> > > the "top level".)
> > >
> > > You could override ev_command_enter, and that might be ok. Here's what
> it
> > > looks like:
> > >
> > >    ev_command_enter_tgsj_
> > > 3 : '". s=. getv ''command'''
> > >
> > > That feels a bit messy though. So maybe it would be better to define
> > > ev_command_turtle_tgsj_ (I am presuming that the command argument to
> > > jdoajax should be 'turtle' to make this work - but I've not tested
> it.).
> > > Then you'd copy the line from ev_command_enter and add your jhrajax
> line
> > > there.
> > >
> > > Thanks,
> > >
> > > --
> > > Raul
> > >
> > >
> >
> --
> (B=)
> ----------------------------------------------------------------------
> 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