/*-------------------------------------------------------------------*/ /* Solutions for Your GUI Applications Development */ /* Using SAS/AF FRAME Technology */ /* by Don Stanley */ /* Copyright(c) 1998 by SAS Institute Inc., Cary, NC, USA */ /* SAS Publications order # 55811 */ /* ISBN 1-58025-301-6 */ /*-------------------------------------------------------------------*/ /* */ /* This material is provided "as is" by SAS Institute Inc. There */ /* are no warranties, expressed or implied, as to merchantability or */ /* fitness for a particular purpose regarding the materials or code */ /* contained herein. The Institute is not responsible for errors */ /* in this material as it now exists or will exist, nor does the */ /* Institute provide technical support for it. */ /* */ /*-------------------------------------------------------------------*/ /* Questions or problem reports concerning this material may be */ /* addressed to the author: */ /* */ /* SAS Institute Inc. */ /* Books by Users */ /* Attn: Don Stanley */ /* SAS Campus Drive */ /* Cary, NC 27513 */ /* */ /* */ /* If you prefer, you can send email to: sasbbu@sas.com */ /* Use this for subject field: */ /* Comments for Don Stanley */ /* */ /*-------------------------------------------------------------------*/ /* Code for Chapter 1 */ page 7 SELECT (popmenu()) ; when (1) ... when (2) ... otherwise ; END ; page10 length rc 3 text $ 30 ; init: call notify('request','_cursor_') ; call notify('promptr','_hide_') ; call notify('request','_set_mode_','NONE') ; call notify('request','_set_instance_method_',' _feedback_', 'sasuser.book16.methods.scl','fback') ; return ; assist: if assist eq 'OFF' then do ; call notify('promptr','_hide_') ; call notify('request','_set_mode_','NONE') ; call notify('request','_cursor_') ; ? if dsid('sashelp.company') then rc=close(dsid('sashelp.company')) ; return ; end ; dsid = open('sashelp.company','i') ; call notify('request','_set_mode_','ALWAYS') ; call notify('promptr','_unhide_') ; call notify('request','_cursor_') ; page 11 call notify('request','_get_text_',text) ; if text ne _blank_ then call notify('request','_feedback_',' ',.,.) ; else call notify('promptr','_repopulate_') ; return ; Close the dataset if it is open. term: if dsid('sashelp.company') then rc=close(dsid('sashelp.company')) ; return ; promptr: call notify('promptr','_get_last_sel_',rc, rc,text) ; call notify('request','_set_text_',text) ; return ; rc = close(dsid) ; if dsid then rc = close(dsid) ; page 12 length text $ 200 varname $ 8 rc 3 ; _self_ = _self_ ; fback: method event $ 20 line 8 offset 8 ; call send(_self_,'_get_text_',text) ; call send(_frame_,'_get_widget_','promptr', list box) ; dsid = dsid('sashelp.company') ; rc = where(dsid,'level5' !! ' like "' !! text !! '%"') ; call send(list box,'_repopulate_') ; endmethod ; page 15 entry prompt $ usertext $ input_length empty_allowed 3; length select1 select2 3 ; page 16 init: call notify('message','_set_text_',prompt) ; call notify('userfld','_set_maxcol_', input_length) ; call notify('userfld','_set_text_',' ') ; call notify('userfld','_cursor_') ; call notify('userfld','_set_tabbable_','on') ; return ; term: if _status_ eq 'C' then do ; usertext = _blank_ ; return ; end ; call notify('userfld','_get_text_',usertext) ; if not empty_allowed & usertext = _blank_ then do ; _status_ = 'R' ; _msg_ = 'ERROR: Data Entry Required Before END' ; return ; end ; return ; userfld: call notify('end','_is_modified_',select1) ; call notify('cancel','_is_modified_',select2) ; if not select1 and not select2 then call execcmd('end') ; return ; if not empty_allowed then call notify(‘userfld’,’_set_required_’,’Y’) ; page 17 if _status_ eq 'C' then usertext = _blank_ ; length paper $ 25 ; init: call display('runok.frame','Enter paper type',paper, 8,0) ; sysrc = sysrc(1); put paper= sysrc=; return ; page 19 tabout: method: /* set object border color to background and then execute the SAS/AF _tab_out_ code. Use background for the color so that the border cannot be seen. */ call send(_self_,'_set_border_color_','background') ; call super(_self_,’_tab_out_’) ; endmethod; tabin: method: /* change the border color and then execute the SAS/AF _tab_in_ default */ call send(_self_,'_set_border_color_','pink') ; call super(_self_,’_tab_in_’) ; endmethod ; page 20 init: call notify('image1','_set_tabbable_','on') ; call notify('image2','_set_tabbable_','on') ; call notify('image1','_set_instance_method_', '_tab_out_', 'sasuser.tabout.override.scl', 'tabout') ; page 21 call notify('image2','_set_instance_method_', '_tab_out_', 'sasuser.tabout.override.scl', 'tabout') ; call notify('image1','_set_instance_method_', '_tab_in_', 'sasuser.tabout.override.scl', 'tabin') ; call notify('image2','_set_instance_method_', '_tab_in_', 'sasuser.tabout.override.scl', 'tabin') ; call notify('image1','_cursor_') ; return tabin: call send(_self_,'_set_border_color_','pink') ; return ; page 22 call execcmd('winsert off') ; page 24 length mytext $ 30 ; init: reg = makelist(); call notify('clickme','_get_region_',reg,'c'); attr = makelist(); rc = setniteml(attr, reg, '_region_'); rc = setnitemc(attr, 'tbox', 'name'); return ; page 25 term: if textbox then call send(textbox,'_term_') ; rc = dellist(reg) ; rc = dellist(attr); return ; clickme: call notify('clickme','_swap_out_') ; if textbox le 0 then textbox = instance( loadclass('sashelp.fsp.efield.class'), attr); call send(textbox,'_swap_in_') ; return ; tbox: call send(textbox,'_get_text_',mytext) ; put mytext= ; call send(textbox,'_swap_out_') ; call notify('clickme','_swap_in_') ; return ; page 27 bpost: method ; call super(_self_,'_bpostinit_') ; page 28 call send(_self_,'_get_widgets_',widget_list) ; if listlen(widget_list) gt 0 then return ; endcheck = makelist() ; rc=insertc(endcheck,'Insert An END Button',-1) ; rc=insertc(endcheck,'Do Not Insert END Button',-1); helpcheck = makelist() ; rc=insertc(helpcheck,'Insert A HELP Button',-1) ; rc=insertc(helpcheck, 'Do Not Insert HELP Button',-1) ; call send(_self_,'_WINFO_','STARTROW',sr) ; call send(_self_,'_WINFO_','STARTCOL',sc) ; call send(_self_,'_WINFO_','NUMROWS',nr) ; call send(_self_,'_WINFO_','NUMCOLS',nc) ; centre = (nc-sc)/2 ; lry = nr - 1 ; lrx = ceil(centre) - 2 ; ulx = lrx - 10 ; uly = lry - 4 ; attr = makelist() ; reg = makelist() ; rc = setniteml(attr,reg,'_region_') ; rc = setnitemc(attr,'C','_justify_') ; rc = setnitemn(reg,ulx,'ulx') ; rc = setnitemn(reg,uly,'uly') ; rc = setnitemn(reg,lrx,'lrx') ; rc = setnitemn(reg,lry,'lry') ; select(popmenu(endcheck)) ; when (1) do ; rc = setnitemc(attr,'END','name') ; end = loadclass('sashelp.fsp.pbutton') ; call send(end,'_new_',buttend,attr) ; call send(buttend,'_set_label_','End') ; call send(buttend,'_set_cmd_','end') ; end ; otherwise ; end ; page 29 select(popmenu(helpcheck)) ; when (1) do ; rc = setnitemc(attr,'HELP','name') ; rc = setnitemn(reg,lrx+4,'ulx') ; rc = setnitemn(reg,lrx+14,'lrx') ; help = loadclass('sashelp.fsp.pbutton') ; call send(help,'_new_',butthlp,attr) ; call send(butthlp,'_set_label_','Help') ; call send(butthlp,'_set_cmd_','Helpmode on') ; end ; otherwise ; end ; rc = dellist(endcheck) ; rc = dellist(helpcheck) ; rc = dellist(attr) ; rc = dellist(reg) ; endmethod ; page 34 entry optional= listid 8 _uattr_ $ class 8 ; length text $ 8 tip $ 70 rc 3 ; init: frameid = getnitemn(listid,'_frame_') ; widget_list = makelist() ; call send(frameid,'_get_widgets_',widget_list) ; tipslist = makelist() ; widget = makelist() ; do i=1 to listlen(widget_list) ; rc = setnitemc(widget, nameitem(widget_list), popl(widget_list)) ; widget_id = nameitem(widget,i) ; if nameditem(widget_id,'TOOLTIP') then rc = setnitemc(tipslist, getnitemc(widget_id,'TOOLTIP'),widget_id); else rc = setnitemc(tipslist,' ',widget_id) ; end ; return ; widgets: page 35 call notify('widgets','_get_last_sel_',rn,issel, text) ; if issel eq 0 then return ; call notify('descr','_set_text_', getnitemc(nameitem(widget,rn),'DESC')); call notify('tooltip','_cursor_') ; widget_id = nameitem(widget,rn) ; call notify('tooltip','_set_text_', getnitemc(tipslist,widget_id)) ; return ; term: if _status_ = 'C' then return ; do i=1 to listlen(tipslist) ; widget_id = nameitem(tipslist,i) ; if getitemc(tipslist,i) ne ' ' then do ; tip = getitemc(tipslist,i) ; rc = setnitemc(widget_id,tip,'TOOLTIP') ; end ; else if nameditem(widget_id,'TOOLTIP') then rc = delnitem(widget_id,'TOOLTIP') ; end ; rc = dellist(tipslist) ; rc = dellist(widget) ; rc = dellist(widget_list) ; return ; tooltip: call notify('tooltip','_get_text_',tip) ; rc = setnitemc(tipslist,tip,widget_id) ; return ; page 37 _self_ = _self_ ; _frame_ = _frame_ ; postinit: method ; call super(_self_,'_postinit_') ; widget_list = makelist() ; call send(_self_,'_get_widgets_',widget_list) ; trackon = 0 ; do i=1 to listlen(widget_list) ; widget_id = popl(widget_list) ; if nameditem(widget_id,'TOOLTIP') then do ; call send(widget_id,'_set_instance_method_', '_cursor_tracker_', 'dgs.toolbox.tooltips.scl', 'tracker') ; call send(widget_id,'_cursor_tracking_on_') ; trackon = 1 ; end ; end ; rc = dellist(widget_list) ; if trackon eq 1 then call send(_frame_,'_cursor_tracking_on_') ; endmethod ; tracker: method x y 8 ; call send(_frame_,'_set_msg_', getnitemc(_self_,'TOOLTIP')) ; endmethod ; FRAME cursor tracking. Blank out the message area. ftrack: method x y 8 ; call send(_frame_,'_set_msg_',' ') ; endmethod ; page 38 init: return ; page 47 if not modified(‘obj1’) then link obj1 ; if not modified(‘obj2’) then link obj2 ; if error(objname) then link