Core Function FileClose
From Sputnik Wiki
				
				
				(Difference between revisions)
				
																
				
				
								
				 (Created page with "<pre> FileClose( <file> ) </pre>  === Description ===  Closes a previously opened text file.  === Parameters ===  ==== file  ====  A variable containing the File handle.  === Ret...")  | 
		m (1 revision)  | 
		||
| (4 intermediate revisions by one user not shown) | |||
| Line 15: | Line 15: | ||
=== Return Value ===  | === Return Value ===  | ||
| − | Success: Returns   | + | Success: Returns true  | 
| − | Failure: Returns   | + | Failure: Returns false if error occurs.  | 
=== Remarks ===  | === Remarks ===  | ||
| Line 26: | Line 26: | ||
<syntaxhighlight lang="sputnik">  | <syntaxhighlight lang="sputnik">  | ||
| − | $File = FileOpen("MyFile.txt", "w")  | + | $File = FileOpen("MyFile.txt", "w");  | 
| − | If   | + | If(isVarObj($File, "file")) // You could just use isObj($File) however adding the "file" will make sure it is indeed a file  | 
| − | 	FileAppend( $File, "This is line 1\n" )  | + | {  | 
| − | 	FileAppend( $File, "This is line 2\n" )  | + | 	FileAppend( $File, "This is line 1\n" );  | 
| − | 	FileAppend( $File, "This is line 3\n" )  | + | 	FileAppend( $File, "This is line 2\n" );  | 
| − | + | 	FileAppend( $File, "This is line 3\n" );  | |
| − | + | 	FileClose( $File );  | |
| − | 	FileClose( $File )  | + | }  | 
| − | + | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
[[Category:Core Function]]  | [[Category:Core Function]]  | ||
Latest revision as of 12:38, 14 June 2015
FileClose( <file> )
Contents | 
Description
Closes a previously opened text file.
Parameters
file
A variable containing the File handle.
Return Value
Success: Returns true
Failure: Returns false if error occurs.
Remarks
N/A
Example
$File = FileOpen("MyFile.txt", "w"); If(isVarObj($File, "file")) // You could just use isObj($File) however adding the "file" will make sure it is indeed a file { FileAppend( $File, "This is line 1\n" ); FileAppend( $File, "This is line 2\n" ); FileAppend( $File, "This is line 3\n" ); FileClose( $File ); }