Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the SAS Session Event Component

You can use the SAS Session Event Component by creating an instance of the class and then adding handlers for the events you want to receive. Each event has an associated data argument that provides information specific to the event (such as a library name or catalog entry name).

You can use a SAS session component to listen for the following events:
Event Name Event Data
catalog entry created Character string containing the four-level name of the newly-created catalog, such as 'WORK.MYCAT.NEW.FRAME'
catalog entry deleted Character string containing the four-level name of the deleted catalog
catalog entry renamed Character string containing the previous four-level name of the renamed entry
fileref assigned Character string containing filename and path, such as 'MYFILE d:\myfile'
fileref deassigned Character string containing filename and path, such as 'MYFILE'
library assigned Character string containing libname, engine, and path of newly created library, such as 'MYLIB V7 d:\mydir'
library deassigned Character string containing libname of deassigned library, such as 'MYLIB'
member created Character string containing name of newly created library member, such as 'WORK.MYDATA.DATA'
member deleted Character string containing name of deleted libary member, such as 'WORK.MYCAT.CATALOG'

Example

The following example instantiates a SAS session event component to check for library information:

  1. Edit a new frame.

  2. In the Components window, add the class Sashelp.Classes.Sessionevent_c.class.

    (Adding this component to the Components window allows you to drop the component on a frame.)

  3. Drag and drop a list box control on the frame, then drag and drop a library list model on top of the list box control.

  4. Drag and drop a SAS session component on the frame (but not on the list box).

  5. Open the Properties window, then expand the tree for Librarylist1 to view its event handlers.

  6. Add a new event handler with the following information: Sender=_SESSION_, Event Name=library assigned, Method Name=onLibraryAssigned.

    When the Add Method dialog appears, click Yes to invoke the New method window. Immediately click OK to end out of the New method window.

  7. Add another event handler for the library deassigned event using Method Name=onLibraryDeassigned. Click Yes to add the new method.

  8. Click the Source button in the New Method window and add the following SCL code:
    onLibraryAssigned: public 
     method libraryInfo:output:char; 
      dcl char libname; 
      dcl num rc;
      libname=scan(libraryInfo,1,' '); 
      rc=insertc(_self_.items, libname, -1); 
      rc=sortlist(_self_.items); 
      _self_._sendEvent('contents updated'); 
    endmethod; 
    onLibraryDeassigned: public method
     libraryInfo:output:char; 
      dcl char libname; 
      dcl num rc index;
      libname=scan(libraryInfo,1,' '); 
      index = searchc(_self_.items, libname); 
      if (index) then do; 
        rc=delitem(_self_.items, index);
        _self_._sendEvent('contents updated'); 
      end; 
    endmethod; 

  9. Compile and save the SCL, then click OK in the New Method window.

  10. Test the frame by assigning a new libname from either the SAS Explorer or Program Editor. You should see the new libname appear automatically in the frame's list box control. Likewise, by removing the libname, you should see the list box update accordingly.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.