The variable 'name' will be set to the contents of the edit control 'name'.
The variable 'bxlist' will be set to the selected value in the listbox
'bxlist'.  You want to add a event handler for user-selection in the
listbox, so:

        list1_bxlist_button=: 3 : 0
                wd 'set name ',bxlist
        )

This will ensure the contents of the edit control constantly track the
selected value in the listbox.  It will also ensure the variable 'name' will
track the value of the variable 'bxlist'.

With a few other cosmetic adjustments, this script might read as in the
postscript.

-Dan

LIST1=: 0 : 0
pc list1;
menupop "File";
menu new "&New" "" "" "";
menu open "&Open" "" "" "";
menusep;
menu exit "&Exit" "" "" "";
menupopz;
xywh 136 8 44 12;cc ok button;cn "OK";
xywh 136 23 44 12;cc cancel button;cn "Cancel"; xywh 64 1 60 60;cc bxlist
listbox; xywh 0 0 60 12;cc name edit; pas 6 6;pcenter; rem form end;
)

NB.  Externalize list of available choices.
LISTITEMS =: ;:'apples bananas cherries dates'

list1_run=: 3 : 0
        wd LIST1
        NB. initialize form here
        wd 'pshow;'
        wd 'set bxlist ',;:^:_1 LISTITEMS
        NB.  Ensure something is selected, initially.
        wd 'setselect bxlist ',":0 <. <:#LISTITEMS
)

list1_close=: 3 : 0
        wd'pclose'
)

list1_cancel_button=: 3 : 0
        list1_close''
)

list1_ok_button=: 3 : 0
        wdinfo 'You have selected "',name,'"' NB. Could also use 'bxlist'
instead of 'name'
)

list1_bxlist_button=: 3 : 0
        wd 'set name ',bxlist
)

NB. Start GUI when script is executed.
list1_run''



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

Reply via email to