Skip to content

writeFile()

Description

The writeFile() function is used to write in a file.

Syntax

JS
writeFile(path: String, content: String, append: Boolean = true) -> Boolean

Parameters

Parameter Type Default Value Mandatory Description
path String ✅ The file path. Can be an absolute or relative (relative to <path_MotorXP-AFM>/bin/assets/scripts).
content String ✅ The content that will be written in the file.
append Boolean true If true — data is added to the end of the file. If false — the file is cleared before writing.

Return value

Type Description
Boolean true if the write operation was successful. In case of an error — returns false, and an error message is printed to the console.

Example

JS
1
2
3
let sampleText = "Sample text";
let result = writeFile("c:/temp/sample.txt", sampleText);
console.info(result);

See Also

readFile()

Last update: 14 August 2025, 18:47