Print List

Function Syntax (princl <l>) / (princf <l>) / (LM:princl <l> [f])
Current Version 1.0
Download PrintListV1-0.lsp
View HTML Version PrintListV1-0.html
Symbol Type Description
l List List to be printed
f String (Optional) Filename of output file
Type Description
List Supplied list argument, else nil & error message if function was unsuccessful

Function Description

This utility function is aimed at AutoLISP developers and will print a supplied list to the AutoCAD command-line or to a plain text file represented by a given filename, with nested lists printed in a hierarchical format so that the structure of the list is clearly displayed.

The main function LM:princl will accept two arguments: the first represents the list to be printed; the second is an optional filename representing a plain text file to which the list may be written.

If the supplied list argument is nil or not of a list data type, the function will not error but will simply print a string representation of the given argument to the command-line or file. Similarly, if a file corresponding to the given filename cannot be created or opened for writing, the function will simply print the supplied list argument to the command-line, without error, ensuring that some output is received.

Included in the program code are two calling functions: princl is a wrapper function which will print a given list to the command-line, removing the requirement for the filename argument; princf also removes the need for a filename argument and will automatically generate a text file in the working directory containing a formatted arrangement of the given list, before opening the file for viewing in Windows Notepad - this is useful for lists which are too large to be viewed at the command-line.

Example Function Call

_$ (princl '(1 2 (3 4 5) (6 7 (8 9 10) (11 12 13) (14 15 16 17)) (18 19 20)))

    (3 4 5)
        (8 9 10)
        (11 12 13)
        (14 15 16 17)
    (18 19 20)


increase · reset · decrease

Designed & Created by Lee Mac © 2010