FileClose: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
{{Server function}} | {{Server function}} | ||
Closes a file handled by [[fileCreate]] or [[fileOpen]]. | |||
== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
bool fileClose ( | bool fileClose ( file theFile ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | ===Required arguments=== | ||
*''' | *'''theFile:''' the file handle to close. | ||
=== | ===Returns=== | ||
Returns ''true'' if succesfully, ''false'' otherwise. | |||
== | ==Example== | ||
This example creates a new text file and writes an string in it. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local | local newFile = fileCreate("test.txt") -- Try creating the file. | ||
if | if newFile then -- Check if was sucessfully created. | ||
fileWrite( | fileWrite(newFile, "This is a test file!") -- Write a text line. | ||
fileClose( | fileClose(newFile) -- Close the file after writing in it. | ||
end | end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
It is important to remember to close the file after done in all operations. | |||
Especially if you wrote something in it. If you do not close the file and the resource crash all changes are lost. | |||
== | ==See also== | ||
{{ | {{File_Functions}} | ||
[[ | [[fileClose]] |
Revision as of 07:25, 10 June 2011
Closes a file handled by fileCreate or fileOpen.
Syntax
bool fileClose ( file theFile )
Required arguments
- theFile: the file handle to close.
Returns
Returns true if succesfully, false otherwise.
Example
This example creates a new text file and writes an string in it.
local newFile = fileCreate("test.txt") -- Try creating the file. if newFile then -- Check if was sucessfully created. fileWrite(newFile, "This is a test file!") -- Write a text line. fileClose(newFile) -- Close the file after writing in it. end
It is important to remember to close the file after done in all operations. Especially if you wrote something in it. If you do not close the file and the resource crash all changes are lost.