that jinput is a copy of what is there in j602. The correct way of
using it as demonstrated in intest.ijs and it should be the same as
that appeared inside Ric's webpage.

However I have never used jinput myself.

require 'jinput'

ABC=: 0 : 0
pc abc;
xywh 136 8 34 12;cc ok button;cn "OK";
xywh 136 23 34 12;cc cancel button;cn "Cancel";
xywh 21 16 97 11;cc edit edit ws_border es_autohscroll;
xywh 51 32 34 12;cc input button;
pas 6 6;pcenter;
rem form end;
)

abc_run=: 3 : 0
wd ABC
NB. initialize form here
wd 'pshow;'
)

abc_close=: 3 : 0
wd'pclose'
)

abc_cancel_button=: 3 : 0
abc_close''
)

abc_input_button=: 3 : 0
input=. conew 'jinput'
create__input 'Give me some data'
)

NB. jinput callback
input_result=:3 : 0
wd'set edit *',y
)

wd :: ] 'psel abc;pclose'

abc_run''

Пнд, 07 Май 2012, Devon McCormick писал(а):
> Hi -
> 
> this is a recurring question but the answer keeps changing as Raul
> indicated.  The extensive answer here -
> http://www.jsoftware.com/jwiki/RicSherlock/Temp/InteractivePrompt - is
> out of date with J7, so I attempted to figure out how to update it.
> 
> It looks like you can do this from the J7 GTK interface:
>    load '~addons/gui/gtkwd/jinput.ijs'
>    input_result=: 3 : 'RESPONSE=: y'
>    create_jinput_ 'Hi"
> 
> to create a window with the prompt "Hi" and return the result in the
> global "RESPONSE".  Unfortunately, this breaks silently on the "try."
> line in "a_ok_button_jinput_" because "COCREATOR" is not defined; this
> is supposed to be a callback to the user-defined "input_result" verb
> (as in the example shown above) in the namespace that created the
> prompt.
> 
> My klugy fix for it is to re-define "a_ok_button_jinput_" as follows -
> by hard-coding the "base" namespace - then ensuring that you run from
> this (which is the default) namespace:
> 
> a_ok_button_jinput_=: 3 : 0
> wd 'pclose'
> try. input_result_base_ edit catch. end.
> destroy''
> )
> 
> So, after loading "jinput.ijs", re-defining as shown and creating
> "input_result" as shown, when you run
>    create_jinput_ 'Hi'
> you'll get a (character vector) variable "RESPONSE" with the user's input.
> 
> On Mon, May 7, 2012 at 10:58 AM, Raul Miller <rauldmil...@gmail.com> wrote:
> > On Mon, May 7, 2012 at 10:20 AM, James Bragg <jsbr...@att.net> wrote:
> >> First, I'm really enjoying learning J.
> >
> > That is good to hear.
> >
> >> Is there a prompt verb? Would "get input" be a prompt verb? Is it possible
> >> to get input from a user in the J Term gtk window or J console and assign 
> >> it
> >> to a variable?
> >
> > There is, but it's ... it's not exactly deprecated, but "neglected"
> > might be accurate.
> >
> > For most purposes, the J command line is the best "prompt verb".
> >
> > For many other purposes, you should be building a "UI" rather than a
> > command line interface.  If you are going to stick to a command line
> > interface, the J command line is usually the best tool for the job.
> >
> > This leaves a neglected niche for the spurious cases where you want a 
> > prompt.
> >
> > In j6.02, this worked in the GUI and I think worked in jconsole on
> > linux/mac (but not in jconsole on windows):
> >
> >   require'misc'
> >   prompt '$ '
> > $ 1 2 3
> > 1 2 3
> >
> > In J7.01, with its various front ends for jconsole (including the
> > browser, via jhs) I do not think that this mechanism is supported
> > robustly.  (But I have not kept up to date on everything that's going
> > on in J7.01 so maybe that aspect has been built out.)
> >
> > FYI,
> >
> > --
> > Raul
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> 
> 
> 
> -- 
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to