# Printing Columns

If you have a large list of items you need to output, you can use the `print.columns()` helper.  Pass an array of simple values to be printed, and columns  will be created on the screen based on the widest item and the terminal width. &#x20;

```javascript
print.columns( directoryList( resolvePath( /lib ) ) )
```

You can also pass a UDF as the second argument which will be called for each item in the array and can return a string with additional formatting text for the print helper to format that item.  The closure receives the following arguments:

* item (string) being printed
* row number
* column number

```
print.columns(
    directoryList( resolvePath( /lib ) ),
    (item,row,col)=>item.endsWith('.txt') ? 'blue' : 'green'
)
```

This example would print out a list of files in the directory, coloring all text files blue, and the rest green.

This helper is the same as the `printColumns` command with the differences being the command accepts no formatting closure and will convert list data into an array or will accept a JSON array directly.

```
printColumns data="1,2,3,4,5" delimiter=","

# or ...
ls --simple | printColumns
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://commandbox.ortusbooks.com/task-runners/task-output/printing-columns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
