Managing Attributes |
SCL list functions such as INSERTC and GETITEMN do not perform explicit "set" and "get" assignments. That is, when you use one of these SCL functions to manipulate a list attribute, the _setAttributeValue method is not invoked for the attribute. The value of the attribute might be changed, but the other actions that occur when an attribute value is changed in a _setAttributeValue call do not execute. The value cannot be validated, the "attributeName changed" event is not sent, and custom access methods do not run. Your SCL code must use explicit assignment operations, such as object.attribute=value, in order to invoke the expected attribute value setting behavior.
For example, consider a frame that contains a list box control named listbox1. If you want to write SCL that adds items to the list box, it might seem logical to write:
/* frame SCL */ dcl num rc; init: rc=insertc(listbox1.items, 'Red', -1); rc=insertc(listbox1.items, 'Blue', -1); rc=insertc(listbox1.items, 'Green', -1); return;
However, because the INSERTC function does not invoke the _setAttributeValue method for items, the "items changed" event is never sent, and the list box is not updated on the frame.
Instead, you can use a list variable and set the items attribute to the value of the list. For example:
dcl list localList=makelist(); init: localList=listbox1.items; rc=insertc(localList, 'Red', -1); rc=insertc(localList, 'Blue', -1); rc=insertc(localList, 'Green', -1); listbox1.items=localList; return;
The _setAttributeValue method runs for the items attribute when the dot notation call sets the value of items. The list box in the frame displays the updated list.
Copyright © 2007 by SAS Institute Inc., Cary, NC, USA. All rights reserved.