Fclose
From SA-MP Wiki
(Difference between revisions)
Revision as of 21:46, 30 January 2014 Smithy (Talk | contribs) ← Previous diff |
Revision as of 23:58, 31 January 2014 Connor Mead (Talk | contribs) Next diff → |
||
Line 28: | Line 28: | ||
[[Category:Scripting Functions]] | [[Category:Scripting Functions]] | ||
[[Category:File Functions]] | [[Category:File Functions]] | ||
+ | |||
+ | [[fr:Fclose]] |
Revision as of 23:58, 31 January 2014
Note: This function name starts with a lowercase letter. |
Description:
Closes a file. Files should always be closed when the script no longer needs them (after reading/writing).
(File:handle)
File:handle | The file handle to close. Returned by fopen. |
Return Values:
true (1) on success false (0) on failure.
Important | The file handle must be valid, and must point to a file successfully opened by fopen. |
new File:example = fopen("Hello.txt", io_append); // Open 'Hello.txt' in the scriptfiles directory if(example) // Check that it was successfully opened { fwrite(example, "Hi there!"); // Write in the file fclose(example); // Close it }
Related Functions
The following functions may be useful, as they are related to this function in one way or another.
- fopen: Open a file.
- fwrite: Write to a file.
- fread: Read a file.
- fremove: Remove a file.