Chapter Contents

Previous

Next
SAS/AF Software: Class Dictionary

Using the Catalog List Model

You can use the Catalog 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 catalog list model to a frame, then set combobox1.model to cataloglist1. To display a list of catalogs in the combo box, specify a value for cataloglist1.library.

You can also use the model in an SCL program to retrieve a list of catalogs from a specified SAS library. Once you specify a valid SAS libary for the object's library attribute, simply query the items attribute to get the list of catalogs. To further qualify the selection, specify other attribute values for the object before you query items.

For example, the following code instantiates a catalog list model and returns a list of all catalogs in the library sasuser:

init: dcl
  sashelp.classes.cataloglist_c.class catobj; 
  dcl list catalogs; 
  dcl num rc;
  catalogs = makelist(); 
  catobj = _new_ sashelp.classes.cataloglist_c();
  catobj.library = 'sasuser'; 
  catalogs = catobj.items; 
  call putlist(catalogs);
  catobj._term(); 
  rc = dellist(catalogs); 
return;

Working with Catalog Names

The Catalog List Model items attribute is populated by a list of catalogs. Each list item is assigned a unique name that is equal to libname.catalog. The unique name appears in the viewer to which you assign the model as long as the model's SASFileDisplayed attribute is set to Yes.

If SASFileDisplayed 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 catalog name. You can query the items attribute list using the NAMEITEM function to determine each catalog's unique name.

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

  2. Add the following SCL code:

listbox1:
  textlabel1.label=nameitem(Cataloglist1.items, Listbox1.selectedIndex);
return;


Chapter Contents

Previous

Next

Top of Page

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