Chapter Contents

Previous

Next
LISTLEN

LISTLEN



Reports the length of an SCL list

Category: List


Syntax
Details
Example
See Also

Syntax

n=LISTLEN(list-id );

n
contains either the length of an SCL list or status information:
>0 the length of a non-empty list
0 the list is empty
-1 the list identifier is invalid.

Type: Numeric

list-id
is the identifier of the list whose length is being queried, or any other number.

Type: Numeric or List


Details

The length of a list is the number of items in the list, excluding the contents of sublists. Because LISTLEN returns -1 if list-id is an invalid list identifier, you can use LISTLEN to determine whether a list exists. For example:

listid=getniteml(envlist('G'),'MYLIST');
invalid=(listlen(listid)=-1);
if invalid then
do;
   put 'MYLIST in the global environment has been deleted.';
   stop;
end;


Example

Create the empty list LISTA, and then insert LISTA into a copy of itself, LISTB. The lengths of the two lists are then computed and are stored in the variables LEN_A and LEN_B.

lista=makelist();
listb=copylist(lista);
listb=insertl(listb,lista);
len_a=listlen(lista);
len_b=listlen(listb);
_msg_='The length of LISTA is '||len_a||' and '||
      'the length of LISTB is '||len_b;

This example shows that the length of LISTA is 0, whereas the length of LISTB is 1.

See Also

MAKELIST

MAKENLIST


Chapter Contents

Previous

Next

Top of Page

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