Document: Append Synchronous
Append the supplied string to the selected file. Use it for a log or growing text document. Include your own newline when each appended entry should occupy a separate line.
Luau
Document:Append(contents: string) -> ()Parameters
Call this method with a Document receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
contents | string | Contents as a Luau string. The string may contain text or binary bytes. |
Returns
()This function returns no values.
Usage notes
No newline is inserted for you. Appending to a folder raises an error.
Document is a handle returned by a file dialog or a folder method. Call its methods with a colon, for example document:Read(). After Delete succeeds, that handle is invalid and further method calls raise an error.
Example
Luau
local document = savefiledialog("Started\n", { suggestedName = "example-log.txt" })
if document then
document:Append("Saved preferences\n")
print(document:Read())
end