Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
os
File
File.close
File.puts
File.printf
File.flush
File.tell
File.seek
File.eof
File.read
File.write
File.getline
File.toString
ListFilesResult
FileStat
Structures
Built-in Variables and Constants
Conventions
Exchanges

Write one or more strings to a file.

puts(data1, data2, ...dataN)

Examples

Write multiple strings to a file.

javascript
function main() { let file = os.open("output.txt", "w+") let bytes = file.puts("Hello", " ", "World", "!") Log("Bytes written:", bytes) // Output: Bytes written: 12 file.seek(0, 0) let data = file.read() Log("data:", data) // Output: data: Hello World! // If the file is opened with os.open("output.txt", "w") (write-only), read() throws // file.puts() // error: puts requires at least 1 argument at main file.puts(", Hello FMZ!") file.seek(0, 0) data = file.read() Log("data:", data) // Output: data: Hello World!, Hello FMZ! file.close() }

Returns

TypeDescription

number

Returns the actual number of bytes written.

Arguments

NameTypeRequiredDescription

data

string

Yes

String data to be written, multiple parameters can be passed.

See Also

Remarks

Multiple string parameters can be written at once, they will be concatenated in order and then written.