Difference between revisions of "(File):write"
m (Added some see also's) |
(Added missing Data variant) |
||
Line 1: | Line 1: | ||
− | Write data to a file | + | Write data to a file. |
+ | |||
+ | == Function == | ||
+ | === Synopsis === | ||
+ | <source lang="lua"> | ||
+ | success = File:write( data, size ) | ||
+ | </source> | ||
+ | === Arguments === | ||
+ | {{param|string|data|The string data to write.}} | ||
+ | {{param|number|size (all)|How many bytes to write.}} | ||
+ | === Returns === | ||
+ | {{param|boolean|success|Whether the operation was successful.}} | ||
+ | |||
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
Line 6: | Line 18: | ||
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param| | + | {{param|Data|data|The Data object to write.}} |
− | {{param|number|size (all)|How many bytes 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.}} |
− | + | ||
− | '''Writing to multiple lines''': | + | == Notes == |
+ | '''Writing to multiple lines''': In Windows, some text editors (e.g. Notepad) only treat CRLF ("\r\n") as a new line. | ||
<source lang="lua"> | <source lang="lua"> | ||
--example | --example | ||
f = love.filesystem.newFile("note.txt") | f = love.filesystem.newFile("note.txt") | ||
− | f:open() | + | f:open("w") |
− | for i = 1, 10 do f:write("This is line "..i.."!\r\n") end | + | for i = 1, 10 do |
+ | f:write("This is line "..i.."!\r\n") | ||
+ | end | ||
f:close() | f:close() | ||
</source> | </source> | ||
Line 25: | Line 40: | ||
* [[(File):setBuffer|File:setBuffer]] | * [[(File):setBuffer|File:setBuffer]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
− | {{#set:Description=Write data to a file}} | + | {{#set:Description=Write data to a file.}} |
{{#set:Since=000}} | {{#set:Since=000}} | ||
== Other Languages == | == Other Languages == | ||
{{i18n|(File):write}} | {{i18n|(File):write}} |
Revision as of 22:46, 29 December 2013
Write data to a file.
Contents
Function
Synopsis
success = File:write( data, size )
Arguments
Returns
boolean success
- Whether the operation was successful.
Function
Synopsis
success = File:write( data, size )
Arguments
Returns
boolean success
- Whether the operation was successful.
Notes
Writing to multiple lines: In Windows, some text editors (e.g. Notepad) only treat CRLF ("\r\n") as a new line.
--example
f = love.filesystem.newFile("note.txt")
f:open("w")
for i = 1, 10 do
f:write("This is line "..i.."!\r\n")
end
f:close()
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info