Skip to content

4.3. print

Import print to write text to standard output:

use print

func *Main():
    Print("Items: ")
    PrintLn("{}", [3])
    PrintLn()
endfunc

This writes Items: 3, followed by an empty line.

4.3.1 Functions

func Print(fmt : strslice)
func Print(fmt : strslice, args : varargs)
func PrintLn()
func PrintLn(fmt : strslice)
func PrintLn(fmt : strslice, args : varargs)
func PrintFlush()
func PrintSetUnbuffered()

Print writes without a newline. PrintLn appends a newline; its no-argument form writes only that newline.

The one-argument forms write text literally. Braces have a formatting meaning only in the forms that take a varargs argument.

PrintLn("{name}")              // prints {name}
PrintLn("{} = {:04X}", ["id", 255]) // prints id = 00FF

Pass one value directly or group multiple values in a bracketed list. See Text Formatting for widths, precision, number formats, escaping braces, and formatting error behavior.

4.3.2 Buffering

PrintFlush() asks the C runtime to flush standard output. This is useful for a prompt without a newline. PrintSetUnbuffered() disables stdout buffering via the runtime; configure buffering before normal output begins.

These functions use the shared stdout sink and formatter. For custom output sinks or building a string instead of printing, see Text Formatting and String Functions.