Thanks bill, I thought more about the logic of an error part way through the update &. drw process and you were right, the way the program was written it could leave the global setting of 9!:6 changed when an error was caught. I solved this by adding the reset of 9!:7 to the catch option and thus an error will still trigger a reset. I don't think I would have spotted this on my own, so thank you again.
I tried your 'bind' suggestion but because I'm checking it each time I show the display, I think the compile time nature of the binding would be an issue (especially if the display were left up for any length of time) I also added a 'display_cancel=: display_close' line for Brian Schott (sorry I didn't respond sooner). Addition of this line allows me to close the window by pressing ESC on my Mac and I didn't see any downside to this functionality. I welcome any opinions to the contrary. Cheers, bob Here is the current code (excuse the line wraps, I'm not sure how I get around that) NB .= ======================================================================= coerase<'rgtVisual' NB. debug - clear traces of globals coclass 'rgtVisual' NB. --------------------------------------------------------- NB. This script creates a form that takes tacit sentences NB. entered by the user in a text box and displays the NB. selected format in a listbox. NB. --------------------------------------------------------- DISPLAY=: 0 : 0 pc display dialog;pn "Tacit Display"; xywh 9 156 216 22;cc box edit topmove rightmove bottommove; xywh 248 24 60 11;cc cbFormatBox checkbox leftmove rightmove;cn "Box Format"; xywh 248 40 60 11;cc cbFormatTree checkbox leftmove rightmove group;cn "Tree Format"; xywh 248 56 60 11;cc cbFormatLinear checkbox leftmove rightmove group;cn "Linear Format"; xywh 248 72 60 11;cc cbFormatParens checkbox leftmove rightmove group;cn "Parens Format"; xywh 240 12 95 80;cc format groupbox leftmove rightmove;cn "Display Style"; xywh 0 0 225 150;cc tdisp editm ws_hscroll ws_vscroll es_readonly rightmove bottommove; xywh 248 114 60 11;cc rbDAscii radiobutton leftmove rightmove;cn "Ascii"; xywh 248 131 60 11;cc rbDLine radiobutton leftmove rightmove group;cn "Line"; xywh 240 103 95 47;cc gbDrawStyle groupbox leftmove rightmove;cn "Drawing Style"; pas 6 6;pcenter; rem form end; ) CBFORMAT=: 'cbFormat'&,each ;:'Box Tree Linear Parens' RBD=: 'rbD'&,each ;:'Ascii Line' LINEDRAW =: (16+i.11) { a. ASCIIDRAW=: '+++++++++|-' rbDstate =: 3 : '>((9!:6 '''') -: ASCIIDRAW){;:''rbDLine rbDAscii''' display_run=: 3 : 0 wd DISPLAY wd 'set box *',y wd 'setfont box ',FIXFONT,'; setfocus box;' wd 'setfont tdisp ',FIXFONT,'; setenable tdisp 1;' wd 'set ',(0{::CBFORMAT),' 1;' wd 'set ',(rbDstate ''),' 1;' box=: y update '' wd 'pshow;' ) display_resume=: 3 : 0 wd 'psel display' wd 'set ',(rbDstate ''),' 1;' wd 'set box *',box=: y update'' ) display_close=: 3 : 0 wd'pclose' ) styles=: (4 : 0)"0 _ ".'zzz=. ' , y res=. 5!: x <'zzz' <LF,~ , ,&l...@ucpboxdraw_jijs_"1 ": res ) stD=: 3 : 0 UDRAW=: 9!:6 '' 9!:7 (". >({.RBD) wdget wd 'qd'){ LINEDRAW ,: ASCIIDRAW y ) rstD=: 3 : '9!:7 UDRAW' drw=: stD :. rstD update=: 3 : 0 try. (3 : 'wd ''set tdisp *'', utf8 ; (2 4 5 6#~ 99".> CBFORMAT wdget wd ''qd'') styles y') &. drw box catch. wd 'set tdisp *',13!:12 '' rstD '' end. ) display_box_button=: update ('display_'&,each RBD,each<'_button')=: update ('display_'&,each CBFORMAT,each<'_button')=: update display=: display_run`display_res...@.((<'display') e. {."1...@wdforms) display_z_=: display_rgtVisual_ display_cancel=: display_close display '+/ % #' NB .= ======================================================================= On -May15-2009, at -May15-200911:07 PM, bill lam wrote: > Your logic should work but what if some error occur after setting that > prevent the code to run into completion and jump to the `catch' > branch? Will it also restore old setting there? > > A word of caution for using bind is that it bind the noun at `compile' > time. However it should be ok for this particular application. > > On Fri, 15 May 2009, bob therriault wrote: >> Thank you bill, >> >> I was unaware of 'bind'. One advantage of having so many eyes on my >> code is the depth of experience everyone brings. >> >> The method I used to set the drawing box was to set the global code >> using 9!:7 according to the radio button pressed, display with those >> characters and then reset to the viewer's original setting so that >> the >> global code is only different during the use of update and does not >> leave the viewers session in a different format. By using 9!:6 to >> check the status in both display_run and display_resume, the form >> will >> initialize correctly to the user's current choices. I would welcome >> any advice you have on better ways to do this. My choice works, but >> is >> not elegant (although I did enjoy using &. for the set/reset with >> update). >> >> Cheers, bob >> >> On -May15-2009, at -May15-20098:58 PM, bill lam wrote: >> >>> Hi Bob, >>> >>> Will it reset global drawing box inside the catch codes? Btw you >>> may >>> use the conjunction `bind' to construct a verb that igore its >>> argument. eg. (untested) >>> >>> rstD=: 9!:7 bind UDRAW >>> >>> -- >>> regards, >>> ==================================================== >>> GPG key 1024D/4434BAB3 2008-08-24 >>> gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 >>> 唐詩260 李益 江南曲 >>> 嫁得瞿塘賈 朝朝誤妾期 早知潮有信 嫁與弄潮兒 >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> >> ---------------------------------------------------------------------- >> 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 > 唐詩177 岑參 奉和中書舍人賈至早朝大明宮 > 雞鳴紫陌曙光寒 鶯囀皇州春色闌 金闕曉鐘開萬 > 戶 玉階仙仗擁千官 > 花迎劍珮星初落 柳拂旌旗露未乾 獨有鳳凰池上 > 客 陽春一曲和皆難 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm