Core Function FileAppendBinary
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> FileAppendBinary( <file>, <binary-array> ) </pre> === Description === Append the data from a binary variable to the end of a previously opened file. === Parameters === ...") |
m (1 revision) |
||
(5 intermediate revisions by one user not shown) | |||
Line 19: | Line 19: | ||
=== Return Value === | === Return Value === | ||
− | Success: Returns | + | Success: Returns true. |
− | Failure: Returns | + | Failure: Returns false if error occurs. |
=== Remarks === | === Remarks === | ||
This will always write to the end of the file. | This will always write to the end of the file. | ||
+ | |||
+ | It would be silly to put an ASCII parameter on this function because YOU decide what the binary data contains. | ||
=== Example === | === Example === | ||
<syntaxhighlight lang="sputnik"> | <syntaxhighlight lang="sputnik"> | ||
− | $binary1 = Pack(" | + | $binary1 = Pack("A*", "Hello World!\n"); |
− | $binary2 = Pack(" | + | $binary2 = Pack("A*", "Hi there\n"); |
− | $binary3 = Pack(" | + | $binary3 = Pack("A*", "This will be line 3\n"); |
− | $File = FileOpen("MyFile.txt", "w") | + | $File = FileOpen("MyFile.txt", "w"); |
− | If | + | If ( isVarObj($File, "file") ) |
− | FileAppendBinary( $File, $binary1 ) | + | { |
− | FileAppendBinary( $File, $binary2 ) | + | FileAppendBinary( $File, $binary1 ); |
− | FileAppendBinary( $File, $binary3 ) | + | FileAppendBinary( $File, $binary2 ); |
− | FileClose( $File ) | + | FileAppendBinary( $File, $binary3 ); |
− | + | FileClose( $File ); | |
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Latest revision as of 12:38, 14 June 2015
FileAppendBinary( <file>, <binary-array> )
Contents |
Description
Append the data from a binary variable to the end of a previously opened file.
Parameters
file
A variable containing the File handle.
binary-array
The binary variable with bytes to write to the end of the file.
Return Value
Success: Returns true.
Failure: Returns false if error occurs.
Remarks
This will always write to the end of the file.
It would be silly to put an ASCII parameter on this function because YOU decide what the binary data contains.
Example
$binary1 = Pack("A*", "Hello World!\n"); $binary2 = Pack("A*", "Hi there\n"); $binary3 = Pack("A*", "This will be line 3\n"); $File = FileOpen("MyFile.txt", "w"); If ( isVarObj($File, "file") ) { FileAppendBinary( $File, $binary1 ); FileAppendBinary( $File, $binary2 ); FileAppendBinary( $File, $binary3 ); FileClose( $File ); }