LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (December 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 24 Dec 2004 17:54:49 +0000
Reply-To:     Phil Holland <news@HOLLANDNUMERICS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Phil Holland <news@HOLLANDNUMERICS.COM>
Organization: Holland Numerics Ltd
Subject:      Re: Using a popmenu to write text into an object within a Form Vi
              ewer
Content-Type: text/plain;charset=us-ascii

Randy and Richard,

Many thanks for your excellent assistance. My latest version incorporates ideas from both solutions, although Randy's solution did actually retain most of my original coding, which made his mods easier to include.

Comments: (1) Although my original example contained a character field, gender, my full application includes a number of numeric fields. This was a point I hadn't spotted until I saw Richard's numeric-specific code: fv.modelId._setColumnValue ('Age', newValue); (2) Fortunately, I have complete control over the contents of the lookup tables, as I don't want the user to be able to manually input more than the initial SubjectID value, and numeric answers to questions. The Gender lookup will only contain 'F' and 'M'. The NODUP is there in case I forget to de-dupe the other lookups, which should all be in 'title' case, and because I generate this code for all fields via a macro. The lookup tables will all be relatively small, so the performance hit will, hopefully, not be significant. (3) Nice features from Richard's solution: - Switching off popups when not in Edit mode: if index (ds.editMode, 'Edit') = 0 then return; - Adding extra redundant (and non-runnable!) code after the methods to prevent warning errors during compilation: _self_=_self_; rc=rc; sysrc=sysrc; - I'm not intending to override the '_init' method of the TextEntry_c class in this application, but it will be top of my customization tasks if I ever work on a similar SAS/AF application again.

I wasn't expecting such an extensive collection of solutions to my query, and am extremely grateful for this early Christmas present! I definitely owe both of you!

Season's greetings.............Phil Holland

In message <438F6013067F9A40B8260C1AD2C29F39067620D9@remail1.westat.com>, Randy Herbison <RandyHerbison@WESTAT.COM> writes >Phil, > >I think the problem is that the SAS Data Set Model doesn't know about the >edited cell. You can use the SAS Data Set Model's _setColumnText() method, >instead of setting the text entry control's text attribute, to update the >data set. This seems to work properly: > >gender_onClick: >method; > dcl object formvID; > _frame_._getWidget('formviewer1',formvID); > ds_gender=open("gender"); > lst_gender=makelist(); > n_gender=0; > rc=lvarlevel(ds_gender,"gender",n_gender,lst_gender); > rc=sortlist(lst_gender,"NODUP VALUE"); > rc=0; > rc=popmenu(lst_gender,15); > if rc>0 then _self_.text=getitemc(lst_gender,rc); > formvID.modelID._setColumnText('gender',getitemc(lst_gender,rc)); > put "gender: " _self_.text _all_; > if ds_gender>0 then ds_gender=close(ds_gender); > if lst_gender>0 then lst_gender=dellist(lst_gender); >endmethod; > > >I got the formviewer's name from the frame and then used the viewer's >ModelID attribute to call the SAS Data Set Model's _setColumnText() method. >I also deleted the call to the text entry control's _refresh() method. > >I don't think the NODUP option for the SORTLIST function does anything here. >LVARLEVEL should return only unique values. If you would like to make sure >that the popup menu includes only one value per gender, and not both 'f' and >'F', you can add the IGNORECASE option to your list of SORTLIST options to >get just one of the values. But, I don't think you can use SORTLIST options >alone, to guarantee which of the values will be kept. In other words, your >list may come out as 'f','M'. You may need to use a clean lookup table or >convert the values to a single case before using SORTLIST. > >RandyHerbison@westat.com > > >-----Original Message----- >From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Phil >Holland >Sent: Wednesday, December 22, 2004 11:20 AM >To: SAS-L@LISTSERV.UGA.EDU >Subject: Using a popmenu to write text into an object within a Form Viewer > > >I'm using lookup SAS tables to populate a popmenu list with unique valid >values for each object in a Form Viewer object linked to a SAS Data Model. > >I've created an override for the _onClick method in mainMethods.scl, which >is intended to allow only the selected value to be placed in the Text Entry >object: > >gender_onClick: >method; > ds_gender=open("lookup.gender"); > lst_gender=makelist(); > n_gender=0; > rc=lvarlevel(ds_gender,"gender",n_gender,lst_gender); > rc=sortlist(lst_gender,"NODUP VALUE"); > rc=0; > rc=popmenu(lst_gender,15); > if rc>0 then _self_.text=getitemc(lst_gender,rc); > _self_._refresh(); > put "gender: " _self_.text _all_; > if ds_gender>0 then ds_gender=close(ds_gender); > if lst_gender>0 then lst_gender=dellist(lst_gender); endmethod; > >In the Form Viewer SCL in subject_table.scl, I test for missing values as >follows: > >dcl char(2) choice; > >gender: > if gender=' ' then do; > choice=messageBox({'ERROR: Missing Gender'},'S','O','Subject'); > _self_._errorOnColumn("gender"); > end; > else do; > _self_._errorOffColumn("gender"); > end; > return; > >On clicking the Text Entry object a popmenu appears and the selected item is >seen in the box, but is not copied into the underlying SAS table when I move >to another record. > >Why? > >..............Phil Holland > >-- >-------------------------------------------------------- >Holland Numerics Ltd > 94 Green Drift, Royston, Herts SG8 5BT, UK > mobile : +44-(0)7714-279085 > email : <NEWS@hollandnumerics.com> > URL : http://www.hollandnumerics.com/ >--------------------------------------------------------

-- -------------------------------------------------------- Holland Numerics Ltd 94 Green Drift, Royston, Herts SG8 5BT, UK mobile : +44-(0)7714-279085 email : <NEWS@hollandnumerics.com> URL : http://www.hollandnumerics.com/ --------------------------------------------------------


Back to: Top of message | Previous page | Main SAS-L page