The wait
command allows you to create a form which bypasses the standard event handler mechanism. When it is used, other forms are disabled - this is referred to as a modal form, and is typically used where you want the user to respond to a query, or acknowledge an information message. The mechanism is similar to that used in Windows Common Dialog Boxes.
The wait
command shows your form, disables events except for that form, and waits for an event. After an event occurs, you can use wd'q'
to query the event and respond to it. Events for other forms are only enabled when the form is closed.
For example, the following creates a form with a list box. When you select an entry, and click OK, the form is closed and the index of your entry is returned. While the form is running, other J windows are disabled.
PICKNUM=: 0 : 0 pc picknum; xywh 70 9 34 12;cc ok button;cn "OK"; xywh 8 8 50 57;cc nos listbox; pas 6 6;pcenter; ) picknum=: 3 : 0 wd PICKNUM wd 'set nos zero one two three four' wd 'setselect nos 0' wd 'wait' res=. wd 'q' wd 'pclose' ndx=.({."1 res)i.<'nos_select' ".>{:ndx{res )
When you use a wait command, take care that the form has some means of closing itself, for example, by defining the form with style closeok
, or explicitly closing the form after the wait is ended.