Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Context Sensitive Menus to Enter Values in a SAS/AF Data Table Object Richard A. DeVenezia.

Similar presentations


Presentation on theme: "Using Context Sensitive Menus to Enter Values in a SAS/AF Data Table Object Richard A. DeVenezia."— Presentation transcript:

1 Using Context Sensitive Menus to Enter Values in a SAS/AF Data Table Object Richard A. DeVenezia

2 Context Menus n Widespread use ä Windows ä Office 97 ä SAS n Right mouse click ä Present menu of choices applicable to task at hand

3 Sample Application n Enter data for a fitness study n Add columns to SASUSER.FITNESS –SMOKES –DIET –EXERCISE n Hands off data entry using context menus

4 SASUSER.FITNESS n SMOKES ä Number of packs smoked a day n DIET ä Diet followed at time of fitness measures n EXERCISE ä Comma separated list of types of regular exercises performed

5 SAS/AF Front End

6 Default Context Menu

7 Desired Context Menus n SMOKES ä List of numbers n DIET ä List of diets n EXERCISE ä List of exercises –Add or remove an exercise from subjects list of exercises

8 Desired Context Menus

9 Control of Context Menu n Max Packs ä Restricts number of packs listed in menu n Exercises ä Restricts number of comma separated exercises n Life Style Choices ä Control data set

10 Life Style Choices n Data set of choices to be shown in context menus n Aspect value matches name of column in table being edited

11 SAS/AF Makes It Happen n Frame class n Data Table class n Methods n SCL Lists n WPOPUP command –Causes the pop up menus for a window to appear –By default under Windows (and UNIX), this command is associated with the right mouse button

12 Making the FRAME entry n Issue command ä BUILD SASUSER.NESUG99.MAIN.FRAME ä This creates an instance of a Frame class n Make a Data Table Right click in Frame and select Make or Issue command RM MAKE ä Create an instance of a Data Table class named FITNESS

13 Data Table: Command Processing n Right click on the Data Table Select Object Attributes –Left click on Command Processing... n Note the Popmenu Processing setting ä Use _POPUP_ method n This is the hook for installing the popmenu, I.e. the context menu

14 FRAME: Core Concepts n Override Data Table _POPUP_ method ä This becomes the WPOPUP event handler n Attach column handler specifiers to the Data Table widget for the event handler to use

15 FRAME: Sample n Override _POPUP_ ä call send (_frame_, '_get_widget_',FITNESS',tabid); call send (tabid, '_SET_INSTANCE_METHOD_','_POPUP_', 'SASUSER.NESUG99.CONTEXT.SCL', 'POPUPCEL');

16 FRAME: Sample n Attach column handler specifiers ä rc = setnitemn (tabid, _smokes, 'RMB_LIST_FOR_SMOKES'); rc = setnitemn (tabid, _diet, 'RMB_LIST_FOR_DIET'); rc = setnitemc (tabid,'CONTEXT:EXERCISE', 'RMB_LIST_FOR_EXERCISE'); n Both _smokes and _diet are SCL lists made and populated in INIT, and repopulated by user front end actions

17 Column Handler: Core Concept n A column handler specifier is a named item attached to the Data Table widget Item name is RMB_LIST_FOR_ n Item value is –numeric: event handler assumes it is an SCL list id –character: event handler assumes it is an SCL method defined with statement: method _self_ 8 row 8 column_name $32 _pop 8;

18 WPOPUP Event Handler Method statement must conform to: method plist sel 8; n plist ä the SCL list that is about to be popmenued n sel ä the number of the item selected n Neither argument is used in the sample application

19 Event Handler Sample Catalog entry SASUSER.NESUG99.CONTEXT.SCL Has this method statement in it POPUPCEL: method plist sel 8;

20 Event Handler Concepts n Obtain cell coordinates where popup occurred n Obtain column name cell is in n Check for column handler specifier n Set active cell to popup cell n Get column type n Dispatch column handler ä Special case for row 0

21 Event Handler Details n Obtain cell coordinates ä _poprow = makelist(); _popcol = makelist(); call send (_self_,_GET_POPUP_CELL_, _poprow, _popcol); n Obtain column name ä col = getnitemn (_popcol,1); call send (_self_,_GET_DISPLAYED_COLUMN_NAME_, col, colname);

22 Event Handler Details n Check for column handler specifier ä handlerItem = namedItem (_self_,RMB_LIST_FOR_ || colname); n Set active cell ä call send (_self_,_SET_ACTIVE_CELL_, _poprow, _popcol); n Get column type ä call send (_self_,_GET_COLUMN_ATTRIBUTE_, colname, TYPE, coltype);

23 Event Handler Details n Dispatch column handler ä select itemType (_self_,handlerItem); when (N) link popItemN; when (C) link popItemC; otherwise; end; n Special case (not done in Sample) ä If row=0 call code specific to a column header ä Sorting, formatting, column order, etc...

24 Column Handler Dispatchers n popItemN: ä Column handler specifier is an SCL list n popItemC: ä Column handler specifier is a method name –Term context method used in later slides n Both dispatchers link to setCell: ä Places value selected from context menu into the popup cell or selected region

25 popItemN: Details n Simplest case n All work was done in the FRAME n Just popmenu the SCL list ä _pop = getItemN(_self_, handlerItem); if listlen (_pop) > 0 then do; choice = popmenu (_pop); if choice > 0 then link setCell; end;

26 popItemC: Concepts n Dispatching is easy ä Writing the method being dispatched is harder n Get the context method n Call the context method ä No error checking, bad method calls cause error messages in the Log Must conform to method _self_ 8 row 8 column_name $32 _pop 8;

27 popItemC: Concepts n _pop is an SCL list made by dispatcher and passed to context method ä Upon return –If _pop is not empty n dispatcher will present menu and insert values into table –If _pop is empty or invalid (deleted) n dispatcher will do nothing and exit normally n Context method can perform any actions ä Value insertion not required

28 popItemC: Details Get the context method and call it ä popcol_method = getitemc (_self_, handlerItem); _pop = makelist (); pophold = _pop; call method (scan (popcol_method,1,':'), scan (popcol_method,2,':'), _self_, row, colname, _pop); ä if listlen (_pop) > 0 then do; choice = popmenu (_pop); if choice > 0 then link setCell; end; n Context method ignores _pop to prevent setCell

29 popItemC: Concepts n Why let method prevent setCell ? ä Value inserted into table not applicable to region select ä Additional flexibility –requires more work –method should use techniques similar to setCell: if it wants to insert a value into the table –method is called with arguments sufficient enough to do setCell: like processing

30 setCell: n Long winded grunt code due to filling selected region feature n Methods used: ä _GET_SELECTIONS_ ä _GET_DATASET_ATTRIBUTES_ ä _LOCK_ROW_ / _UNLOCK_ROW_ ä _CLEAR_SELECT_ ä _SET_ACTIVE_CELL_ ä _SET_COLUMN_TEXT_ / _VALUE_

31 Context Method Statement Must conform to method _self_ 8 row 8 column_name $32 _pop 8; n _SELF_ ä Data Table widget id n ROW & COLUMN_NAME ä Data Table cell where popup event occurred n _POP ä SCL list to be populated

32 Exercise Context Method Catalog entry SASUSER.NESUG99.CONTEXT.SCL Has this method statement in it EXERCISE: method _self_ 8 row 8 column_name $32 _pop 8 ; n Term Exercise method used in later slides

33 Exercise Method Overview n End result ä Exercise value is a comma separated list of M values taken from the N choice values in LIFESTYL data set where aspect=EXERCISE n Coupled with a FRAME object ä Input field nExer in the FRAME controls M

34 Exercise Method Concepts n Get FRAME Data Table resides in n Get nExer value from FRAME n Get current value of Exercise n Check if more exercises allowed n Make a context menu that shows remove before any exercise already present, and add before any exercise not present n Update value in table accordingly

35 Exercise Method Details n Get nExer value from FRAME Data Table is in ä call send (getnitemn (_self_, '_FRAME_'), '_GET_NUM_VAR_', 'NEXER', nExer); n Get current value of Exercise ä call send (_self_, '_GET_COLUMN_TEXT_', column_name, exercise); n Check if more exercises allowed ä allow_more=(scan(exercise,nExer, ',') = '');

36 Exercise Method Details n Make a context menu to show values with remove and add prefaces ä Involved bit of code using two SCL lists ä List1 are exercises currently in value ä List2 are exercises obtained from lookup –open LIFESTYL(WHERE=(ASPECT="EXERCISE")) –populate using LVARLEVEL function

37 Exercise Method Details n Update value in table ä call send (_self_, '_LOCK_ROW_', row); call send (_self_, '_SET_COLUMN_TEXT_', column_name, exercise); call send (_self_, '_UNLOCK_ROW_');

38 Conclusion n Dare to dream up intuitive interfaces n SAS/AF is superbly capable n You can only maximize your AF investment with deep understanding Richard A. DeVenezia Sample application available upon request radevenz@ix.netcom.com SAS and SAS/AF are registered trademarks or trademarks of SAS Institute Inc, in the USA and other countries. indicates USA registration.


Download ppt "Using Context Sensitive Menus to Enter Values in a SAS/AF Data Table Object Richard A. DeVenezia."

Similar presentations


Ads by Google