Difference between revisions of "(File):write"

(Notes)
Line 3: Line 3:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
success = File:write( data )
+
success = File:write( data, size )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 
{{param|string|data|The data to write}}
 
{{param|string|data|The data to write}}
 +
{{param|number|size (all)|How many bytes to write}}
 
=== Returns ===
 
=== Returns ===
 
{{param|boolean|success|Whether the operation was successful}}
 
{{param|boolean|success|Whether the operation was successful}}

Revision as of 09:17, 13 December 2012

Write data to a file

Function

Synopsis

success = File:write( data, size )

Arguments

string data
The data to write
number size (all)
How many bytes to write

Returns

boolean success
Whether the operation was successful

Notes

Writing to multiple lines: Use the escape characters \r\n in combination to move to the next line for writing. If only \n is used most text editors will show the line breaks properly while some (like Notepad for Windows) will not. It seems \r\n is a safe default.

--example
f = love.filesystem.newFile("note.txt")
f:open()
for i = 1, 10 do f:write("This is line "..i.."!\r\n") end
f:close()

See Also


Other Languages