# Console

Functions for working with a console described here.

* [ClearCarriage( str input ) str](/stdlib/console.md#clearcarriage-str-input-str)
* [Print( anytype par... ) int](/stdlib/console.md#print-anytype-par-int)
* [Println( anytype par... ) int](/stdlib/console.md#println-anytype-par-int)
* [ReadString( str text ) str](/stdlib/console.md#readstring-str-text-str)

## Operators

| Operator     | Result | Description                                                                                                                                                      |
| ------------ | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **\|\|** str | int    | This unary operator writes a string to standard output but it trims whitespace characters in the each line before printing. Returns the number of bytes written. |

```
run {
   ||`One
      Two
      Three
      `
}
/* It prints
One
Two
Three
*/
```

## Functions

### ClearCarriage(str input) str

The function *ClearCarriage* clears the string from all carriage return characters **\r** back to the previous line break character **\n**. It is recommended to use *ClearCarriage* if you get the console output when calling the **Run** function. The function is called automatically in case of *str s = $ command line* operator.

```go
buf dirout
Run("myapp", stdout: dirout)
// dirout == Start\nPercent: 0%\rPercent: 50%\rPercent: 100%\nFinish
ret = ClearCarriage(str(dirout))
// ret == Start\nPercent: 100%\nFinish
```

### Print(anytype par...) int

The *Print* function formats using the default formats for operands of any types and writes to standard output. Spaces are added between operands when neither is a string. *Print* returns the number of bytes written.

### Println(anytype par...) int

The *Println* function formats using the default formats for operands of any types and writes to standard output. Also, it writes a new line character to standard output at the end. Spaces are always added between operands. *Println* returns the number of bytes written.

### ReadString(str text) str

The *ReadString* function reads the standard input until the first occurrence of '\n' (Enter key). It returns a string containing the data up to. If the *text* parameter is not empty, the function prints this text before reading input.


---

# 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://docs.gentee.org/stdlib/console.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.
