Hey everybody, Sorry about the delay.
In any case, I added display character functionality to the form (trying to stay true to Oleg's approach). Probably the biggest challenge I had was figuring out how to use &. to set and reset the character type prior to and after running update. The breakthrough was using y [ in stD to pass the box argument through to update. It allows side effects such as setting 9!:7, before continuing on with the update display. Here is the code, comments are appreciated - 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; 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 : 'y [ (9!:7 ( (". >({.RBD) wdget wd ''qd''){ LINEDRAW ,: ASCIIDRAW)) [ (UDRAW=: 9!:6 '''')' 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 '' 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 '+/ % #' NB .= ======================================================================= On -May2-2009, at -May2-20097:36 PM, bill lam wrote: > On Sat, 02 May 2009, bob therriault wrote: >> I still wonder about assigning display to the z locale. I think this >> may be part of Oleg's suggestion for a new name, 'disprep', but I am >> concerned that the user would have to know which names are already in >> the z locale (no matter how obscure) before they safely used this >> program. Two solutions I have thought about are checking the z locale >> programmatically before assigning, or making this script a class and >> the form an object instance. I'm working on my object oriented >> understanding, so this may be a silly suggestion. > > I think you need not too worry name collision unless you intended to > submit your code to the J base library. > > If you intend you rerun the code in its `base' locale, a simpler way > of not using display_resume will be close the form first or just > ignore any anticipated error. > replace the line > wd DISPLAY > with > wd ::0: 'psel display;pclose' > wd DISPLAY > or just > wd ::0: DISPLAY > > If you intend to run in a new instance. It needs to rename > `display_run' to `create' and add a verb `destroy' for cleanup. > Then run the program by '+/%#' conew 'rgtVisual' > (untested) > > -- > regards, > ==================================================== > GPG key 1024D/4434BAB3 2008-08-24 > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 > 唐詩122 王維 漢江臨眺 > 楚塞三湘接 荊門九派通 江流天地外 山色有無中 > 郡邑浮前浦 波瀾動遠空 襄陽好風日 留醉與山翁 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm