Chapter Contents

Previous

Next
PUTLIST

PUTLIST



Displays the contents of an SCL list in the LOG window

Category: List


Syntax
Details
Examples
Example 1: Displaying a List with Indented Values
Example 2: Replacing a Numeric Item with a Sublist Item
Example 3: Adding a List to Itself as a Sublist
See Also

Syntax

CALL PUTLIST(list-id<,label<,indent>>);

list-id
is the identifier returned by the function that created the list.

Type: Numeric or List

label
specifies the label for the printed output.

Type: Character

indent
is the number of characters to indent list items in the printed list.

Type: Numeric


Details

After printing the optional label, PUTLIST prints a left parenthesis '(' to mark the beginning of the list, followed by the list of items separated by blanks. Each named item is preceded by its name and an equal sign (=), but nothing is printed before items that do not have names. PUTLIST ends the list with a right parenthesis ')', followed by the list's identifier number within square brackets.

If the value for indent is greater than or equal to 0, the list is printed in a vertical format where each list item is printed on its own line. Sublists are indented the number of spaces to the right that is specified by indent.

If the list contains sublists that have been deleted, PUTLIST identifies each invalid list identifier with the text <invalid list id>[listid].


Examples

The following examples are based on an SCL list whose list identifier is stored in the variable A. This list contains the numbers 17 and 328 plus the character value "Any characters". These examples display the list in several ways:


Example 1: Displaying a List with Indented Values

Print a list and indent the list items:

call putlist(a,'A=',2);
The above statement produces the following output:
A=(  17
     328
     'Any characters'
   )[7]

Example 2: Replacing a Numeric Item with a Sublist Item

Replace the second item in the list A with the list identifier for sublist B, which contains the values -4.75 and 12.875:

/*  Assign the second item to list B.  */
   a=setiteml(a,b,2);
   name=nameitem(a,1,'MIN');
   name=nameitem(a,2,'B');
   call putlist(a,'A=',2);
These statements produce the following output:
A=(  MIN=17
  B=(  -4.75
       12.875
  )[5]
  'Any characters'
  )[7]

Example 3: Adding a List to Itself as a Sublist

If a sublist appears more than once in the list that is being printed, PUTLIST prints only the following for the second and subsequent occurrences of the list:

(...) [listid-number]

To view the full contents of the list, scan the output of PUTLIST for other occurrences of [listid-number]. This prevents infinite loops if a list contains itself.

Create and display a recursive list:

r1=makelist();
   r1=setnitemn(r1,1,'X');
   r1=setniteml(r1,r1,'SELF');
   call putlist(r1,'R1=',2);
These statements display the following information in the LOG window. Note that the full contents of the list that has the identifier 7 are printed only once. The other occurrence is represented as (...)[7].
R1=(  X=1
      SELF=(...)[7]
   )[7]

See Also

MAKELIST

MAKENLIST


Chapter Contents

Previous

Next

Top of Page

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