Chapter Contents


SAS/AF Software: Class Dictionary

Using the Library List Model

You can use the Library List Model class in conjunction with a viewer control for model/view communication. When you drop a model on a control in a frame, or you set the control's model attribute to the name of the instantiated model object, the items attribute of the view is automatically set to the items attribute of the model when you specify the library attribute on the model.

For example, add a combo box control and a library list model to a frame, then set combobox1.model to librarylist1. The list of libraries from librarylist1.items displays in the combo box.

You can also use the library list model in an SCL program to retrieve a list of libraries from the current SAS session. Simply query the items attribute to get the list of libraries. To further qualify the selection, specify other attribute values for the object before you query items.

For example, the following code instantiates a library list model and returns a list of all libraries and their host file paths (by setting the pathDisplayed attribute):

  dcl sashelp.classes.librarylist_c.class libobj;
  dcl list libraries; 
  dcl num rc; 
  libraries = makelist(); 
  libobj = _new_ sashelp.classes.librarylist_c(); 
  libobj.pathDisplayed = 'Yes';
  libraries = libobj.items; 
  call putlist(libraries); 
  rc = dellist(libraries); 

Working with Library Names

The Library List Model items attribute is populated by a list of libraries. Each list item is assigned a unique name that is equal to the name of the library. The unique name appears in the viewer to which you assign the model as long as the model's libraryDisplayed attribute is set to Yes.

If libraryDisplayed is set to No, the name will not appear in the items attribute list, which means it will not display in any associated view. Each item on the list, however, is a named item that also corresponds to the library name. You can query the items attribute list using the NAMEITEM function to determine each library's unique name.

  1. Create a frame with a listbox, librarylist model, and a text label.

  2. Add the following SCL code:

  textlabel1.label=nameitem(Librarylist1.items, Listbox1.selectedIndex);

Chapter Contents



Top of Page

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