In both of the approaches there is one important omission that can backfire with multiple applications of plotting: the created plot object is never destroyed.
(closeok can only be used for simple forms which do not have dependent resources.) The pattern of working with objects like jzplot is simple: you need to bracket with the creation and destruction, and it is easy to do in natural lifecycle of the parent form. run -- creates a form: create and initialize an object update -- event on form: call plot with new data close -- closes a form: destroy the object The classical (but not optimal) reference: http://www.jsoftware.com/jwiki/Plot/Class See this pattern also in dynamic Real-time Plot: http://www.jsoftware.com/jwiki/Scripts/Real-time_Plot NB. ========================================================= NB. minimal jzplot usage pattern require 'plot' MYPLOT=: 0 : 0 pc myplot; xywh 0 0 225 200;cc g0 isigraph ws_border rightmove bottommove; xywh 231 3 40 12;cc update button leftmove rightmove;cn "Update"; pas 2 0;pcenter; rem form end; ) myplot_run=: 3 : 0 wd MYPLOT loc=: conew 'jzplot' NB. create plot object PForm__loc=: 'myplot' NB. define PForm in loc PFormhwnd__loc=: wd 'qhwndp' NB. define PFormhwnd in loc PId__loc=: 'g0' NB. define PId in loc myplot_update_button'' NB. common updater wd 'pshow' ) myplot_close=: 3 : 0 destroy__loc'' wd 'pclose' ) myplot_g0_paint=: 3 : 0 pd__loc 'show' NB. call show in paint handler ) myplot_update_button=: 3 : 0 'density' plot__loc ?25 25$100 NB. draw plot on the form ) myplot_run'' NB. ========================================================= Then it's also easy to make form object-oriented. It's essential, if you want to handle multiple open windows. NB. ========================================================= NB. OO form jzplot usage pattern require 'plot' coclass 'pmyplot' MYPLOT=: 0 : 0 pc myplot; xywh 0 0 225 200;cc g0 isigraph ws_border rightmove bottommove; xywh 231 3 40 12;cc update button leftmove rightmove;cn "Update"; pas 2 0;pcenter; rem form end; ) create=: 3 : 0 wd MYPLOT loc=: conew 'jzplot' NB. create plot object PForm__loc=: 'myplot' NB. define PForm in loc PFormhwnd__loc=: wd 'qhwndp' NB. define PFormhwnd in loc PId__loc=: 'g0' NB. define PId in loc update'' NB. common updater wd 'pshow' ) destroy=: 3 : 0 wd 'psel ',PFormhwnd__loc NB. avoid closing other active form destroy__loc'' codestroy'' wd 'pclose' ) myplot_close=: destroy myplot_g0_paint=: 3 : 0 pd__loc 'show' NB. call show in paint handler ) update=: 3 : 0 'density' plot__loc ?25 25$100 NB. draw plot on the form ) myplot_update_button=: update Note 'test' a=. ''conew'pmyplot' update__a'' NB. remote control destroy__a'' ) NB. ========================================================= --- Fraser Jackson <[EMAIL PROTECTED]> wrote: > Keith, > > You did not describe what your problem is but the following which follows > the Plot Classes help closely may be what you want. > > It provides separately labelled plots. If you want the function executed in > a locale specified by the > left argument that is quite different. > > load 'plot' > > Myplot=: 0 : 0 > pc closeok; > xywh 225 13 150 150;cc g1 isigraph ws_border rightscale bottommove; > pas 2 0;pcenter; > rem form end; > ) > > WDplot=: 3 : 0 > : > a=. conew 'jzplot' > Myplot__a =. Myplot > Myplot__a =. (3 {.Myplot__a),x,2}. Myplot__a > wd Myplot__a > PFormhwnd__a=. wd 'qhwndp' > PId__a=. 'g1' > plot__a y > ) > > 'g0' WDplot 1 2 3 ; 2 0 2 > 'g1' WDplot 2 3 4 ;0 2 0 > 'g2' WDplot 1 2 5 8 9 ;1 2 3 2 1 > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
