Chapter Contents |
Previous |
Next |
SETLATTR |
Category: | List |
Syntax |
rc=SETLATTR(list-id,attributes<,index>); |
0 | successful |
0 | not successful |
Type: Numeric or List
Type: Character
Type: Numeric
Attribute Values for Lists and List Items |
'DEFAULT'
'DELETE'
'FIXEDTYPE'
'NODELETE'
'NOFIXEDTYPE'
'NOUPDATE'
'UPDATE'
Attribute Values for Lists Only |
'ANYNAMES'
'CHARONLY'
'COPY'
'DUPNAMES'
'FIXEDLENGTH'
'HONORCASE'
'NOCHARONLY'
'NOCOPY'
'NODUPNAMES'
'NOFIXEDLENGTH'
'NOHONORCASE'
'NONUMONLY'
'NUMONLY'
'SASNAMES'
Attribute Values for List Items Only |
'ACTIVE'
'INACTIVE'
'AUTO'
'NOAUTO'
'NOWRITE'
'WRITE'
Details |
If index is omitted or zero, the attributes are assigned to the list. Otherwise, the attributes are assigned to the item at the position specified by index. Item attributes are attached to the items in the list, not to the position in the list, so that an item keeps its attributes after the list is rotated or reversed or after other items are inserted or deleted. That is, if you assign the NODELETE attribute to the fourth item in the list and then delete the item at position 2, the item still has the NODELETE attribute even though it is now at position 3.
If a list has the NOCOPY attribute, it is not copied if it is a sublist in a recursive call of COPYLIST. Instead, only the list identifier is copied to the target list, and no recursion takes place on the list. You can still copy a list with NOCOPY if it is the source (top-level) list.
Attribute Pairs |
The attributes for lists and list items come in mutually exclusive pairs. For example, NOUPDATE designates that UPDATE is off. Setting one attribute of a mutually exclusive pair automatically turns off the other. The attribute pairs are shown in the following table.
Attribute | Complement Attribute | Applies To | |
---|---|---|---|
ACTIVE | INACTIVE | Items | |
ANYNAMES | SASNAMES | Lists | |
COPY | NOCOPY | Lists | |
DELETE | NODELETE | Items and Lists | |
DUPNAMES | NODUPNAMES | Lists | |
HONORCASE | NOHONORCASE | Lists | |
NOCHARONLY | CHARONLY | Lists | |
NOFIXEDLENGTH | FIXEDLENGTH | Lists | |
NOFIXEDTYPE | FIXEDTYPE | Items and Lists | |
NONUMONLY | NUMONLY | Lists | |
UPDATE | NOUPDATE | Items and Lists | |
WRITE | NOWRITE | Items and Lists |
The attributes of a list (such as CHARONLY, NUMONLY, FIXEDTYPE, and NOUPDATE) do not apply to sublists that the list contains. You must assign these attributes to the sublists if you want them to have these attributes.
Both list and item attributes are copied by COPYLIST. However, COPYLIST does not copy passwords.
Most of the list functions that alter lists or their contents are affected in some way by list attributes and item attributes. See the documentation for the individual functions to see how they are affected.
Using Passwords to Protect List Attributes from Modification |
You can assign a password to list attributes, which enables you to protect them. The password is stored with the list and must be supplied in subsequent SETLATTR statements in order to modify either list attributes or item attributes. The password is specified as PASSWORD=password in the attribute string. The password may not contain any blanks, but case is significant. For example, the passwords frobble and FROBBLE are different.
The following statements show how to assign a password:
pwd='password=grombaq'; myattr='nodelete noupdate'; rc=setlattr(mylist,myattr||' '||pwd);
If an SCL program attempts to modify the value of one item in MYLIST, the program halts, because the list has the NOUPDATE attribute. If you want to permit updates of the list again, you can execute SETLATTR as follows:
rc=setlattr(mylist,pwd ||'update');
Note: An error condition results if you attempt to alter list attributes without
specifying the PASSWORD= option and password.
You can remove the password from a list with NOPASSWORD=. Thereafter, any SCL program can change attributes or set the password. Either of the following statements removes the previously set password from the list identified by MYLIST:
rc=setlattr(mylist,'no'||pwd); rc=setlattr(mylist,'nopassword=grombaq');
You must supply the correct password in order to remove a password that was previously set.
Example |
The NODELETE list attribute means that the list itself cannot be deleted with DELLIST. The NODELETE item attribute indicates that an item cannot be deleted from the list regardless of the item's type. The following statements show this distinction:
a=makelist(3); b=makelist(); /* Set 3rd item in A to B. */ a=setiteml(a,b,3); /* Give list B the NODELETE attribute. */ /* DELLIST(b) will be an error. */ rc=setlattr(b,'NODELETE'); /* Give the 3rd item in A the */ /* NODELETE attribute. */ /* DELITEM(a, 3) will be an error. */ rc=setlattr(a,'NODELETE',3); /* Move B to the second item in the list */ /* and set the third item with 0. */ a=setiteml(a,b,2); a=setitemn(a,0,3); /* Remove B from list A, */ /* but B still exists. */ /* DELITEM(a,2) will be an error now. */ a=delitem(a,2);
See CLEARLIST and DELLIST for more information about the DELETE and NODELETE attributes.
See Also |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.