Difference between revisions of "(File):write"

(Notes)
(Notes)
Line 10: Line 10:
 
{{param|boolean|success|Whether the operation was successful}}
 
{{param|boolean|success|Whether the operation was successful}}
 
=== Notes ===
 
=== Notes ===
'''Writing to multiple lines''': Use the escape character \n to move to the next line for writing. Some editors may require \r\n in combination to work, your results may vary.
+
'''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.
 
<source lang="lua">
 
<source lang="lua">
 
--example
 
--example

Revision as of 00:04, 21 October 2012

Write data to a file

Function

Synopsis

success = File:write( data )

Arguments

string data
The data 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