Core Function FileWriteLines
FileWriteLines( <file>, <array>, <lineBreak>, <useAscii> )
Contents |
Description
Write an array of lines to previously opened file at the current File Steam pointer location.
Parameters
file
A variable containing the File handle.
array
The array to write to the file.
Each element in the array will be considered a new line for the file.
lineBreak
Optional; The line break to use.
Default: "\n"
useAscii
Optional: Flag to decide if ASCII encoding should be used
True = Save using ASCII encoding
False = Save using UNICODE encoding
Default: false (All strings in Sputnik are Unicode to save them to file you must specifically request ASCII encoding)
Return Value
Success: Returns true
Failure: Returns false if error occurs.
Remarks
You can set the File Steam pointer location with FileSeek( ).
Warning this will not write to the end of the file unless you tell it to with seek so if you want to write to end of the file you should use FileAppendLines( ) instead.
Example
$File = FileOpen("a.txt", "w"); If(isVarObj($File, "file")) { FileWrite( $File, "Test\n" ); FileWrite( $File, "Test2\n" ); FileWriteLines( $File, array("One", "Two", "Three", "Four") ); FileClose( $File ); }
Lets use "<br>" for the line breaks
$File = FileOpen("a.txt", "w"); If(isVarObj($File, "file")) { FileWrite( $File, "Test\n" ); FileWrite( $File, "Test2\n" ); FileWriteLines( $File, array("One", "Two", "Three", "Four"), "<br>" ); FileClose( $File ); }