Chapter Contents |
Previous |
Next |
SETNITEMC, SETNITEML, SETNITEMN, and SETNITEMO |
Category: | List |
Syntax | |
Details | |
See Also |
Syntax |
rc=SETNITEMC(list-id,cval,name,<occurrence <,start-index <,index<,forceup>>>>); |
rc=SETNITEML(list-id,sublist-id,name,<occurrence <,start-index<,index<,forceup>>>>); |
rc=SETNITEMN(list-id,nval,name
,<occurrence <,start-index<,index<,forceup>>>>); |
rc=SETNITEMO(list-id,object-id,name,
<occurrence <,start-index<,index<,forceup>>>>); |
Type: Numeric
Type: Numeric or List
Type: Character
Type: Numeric
Type: Numeric
Type: Numeric or Object
Type: Character
Type: Numeric
Type: Numeric
Note: This parameter is an update parameter. See Input, Output, and Update Parameters for more
information.
Type: Numeric
'N' |
searches according to the list attributes HONORCASE and NOHONORCASE, which are specified with SETLATTR. (This is the default.) |
'Y' |
conducts the name search in uppercase regardless of the list attributes that are specified with SETLATTR. The HONORCASE and IGNORECASE attributes are ignored. |
Type: Character
Details |
SETNITEMC, SETNITEML, SETNITEMN, and SETNITEMO do not make a copy of the list before modifying or inserting an item. The list is modified in place. If the named item is not found in the list (and if the list does not have the FIXEDLENGTH attribute), the item is inserted into the list.
If you specify a variable name for index, then these functions return the index number in the list of the modified or inserted item. You can reference this index to access the same item with these functions and other SCL list functions, as long as the items do not change positions (for example, as a result of an insert or delete operation). If the position of items in a list is stable, then using the index argument and subsequent index-based functions such as SETITEMC rather than name-based functions improves performance, because the list does not have to be searched multiple times to find a name match.
If occurrence and start-index are both positive or both negative, then the search proceeds forward from the start-index item. For forward searches, the search continues only to the end of the list and does not wrap back to the front of the list. If the named item is not found, it is inserted at the end of the list. If occurrence or start-index is negative, the search proceeds backwards from the end to the beginning of the list. For backward searches, the search continues only to the beginning of the list and does not wrap back to the end of the list. If the named item is not found, it is inserted at the beginning of the list.
The result of using SETNITEMC, SETNITEML, SETNITEMN, and SETNITEMO is similar to combining NAMEDITEM and SETITEM, SETITEML, SETITEMN, and SETITEMO, respectively. For example, consider the following statement:
mylist=setnitemc(mylist,'Jones','NAMES',1,1,i);This statement performs the same operations as the following statements:
i=nameditem(mylist,'NAMES'); /* If NAMES isn't found, insert it */ /* at the end of the list. */ if i=0 then mylist=insertc(mylist,'Jones',-1,'NAMES'); else mylist=setitemc(mylist,'Jones',i);
Note: The return value of these functions is not
used to indicate whether an error has been detected. When an error occurs,
the program simply halts.
An error condition results
To check the attributes of a list or list item, use HASATTR. To change attributes, use SETLATTR.
See Also |
GETNITEMC, GETNITEML, GETNITEMN, and GETNITEMO
INSERTC, INSERTL, INSERTN, and INSERTO
SETITEMC, SETITEML, SETITEMN, and SETITEMO
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.