Skip to content

File Reading & Writing

KerbalMissile edited this page Mar 13, 2026 · 3 revisions

Nova provides simple and straightforward commands for interacting with the file system. Whether you want to save data or read it back later, Nova makes it easy to manage.

Writing

Use the write_file function to write text to a file. If the file does not exist, Nova will create it automatically. If it already exists, the content will be overwritten.

- Syntax:

write_file("filename.txt", "text to write goes here")

- Example:

write_file("fruits.txt" "apple,banana,cherry")

This example creates or overwrites a file named fruits.txt with the text apple,banana,cherry.

Memory Writing

To write to memory, it follows the same syntax, but instead of write_file() it becomes mem_write()

Reading

To read the contents of a file, use the read_file function. The content is then returned as a string, which you can store in a variable for further use.

- Syntax:

have variableName = read_file("filename.txt")

- Example:

have fileContents = read_file("fruits.txt"0

put("File contents: " + fileContents)

Memory Reading

To read what you wrote memory, it follows the same syntax, but instead of read_file() it becomes mem_read()

Practical Use

File I/O (input / output, aka. writing / reading) is especially useful when combined with event handlers, such as button clicks, to log actions or save user data.

- Example:

button("Log Click", 20, 110) {

clicked() {

write_file("click_log.txt", "Button clicked at " + current_time())

}

}

Nova Link Sidebar

Built-in Functions & Utilities

Math & Numbers

Variables & Data Types:

Loops & Conditionals:

File Reading & Writing

GUI & Event Handlers

Nova Tools

Inputs

Compiler & Interpreter

VS Code Extension

Clone this wiki locally