API Reference › Builtin functions › file_write
function

file_write

file_write(handle, buf, len)

Writes len bytes from buf to the given stream handle. Get the handle from file_stdout or file_stderr; the buffer is typically a string (whose length you pass with len(buf)) or a raw buffer from bytes. This is the precise, no-frills output primitive that underpins Ludic's own tooling and code generators, where exact bytes matter and the automatic newline of print would get in the way. Pass a byte count that does not exceed the buffer's size.

Parameters

handlea stream handle from file_stdout or file_stderr
bufthe bytes to write (a string or a raw buffer)
lenhow many bytes to write

Example

program WriteTwice {
  handler Emit phase Start {
    let out = file_stdout()
    let heading = "SCORE: "
    let value = "250\n"
    file_write(out, heading, len(heading))
    file_write(out, value, len(value))
  }
}
← All symbols