Core Function FileWriteBinary
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> FileWriteBinary( <file>, <binary-array> ) </pre> === Description === Write the data from a binary variable to previously opened file at the current File Steam pointer loc...") |
m (1 revision) |
||
| (5 intermediate revisions by one user not shown) | |||
| Line 26: | Line 26: | ||
You can set the File Steam pointer location with [[Core Function FileSeek|FileSeek( <file>, <offset>, <flag> )]]. | You can set the File Steam pointer location with [[Core Function FileSeek|FileSeek( <file>, <offset>, <flag> )]]. | ||
| + | |||
| + | 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"> | ||
| − | $a = Pack(" | + | $a = Pack("A*", "Hello World!"); |
| − | $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 |
| − | + | { | |
| − | FileClose( $File ) | + | $zz = FileWriteBinary( $File, $a ); |
| − | + | FileClose( $File ); | |
| + | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] | ||
Latest revision as of 12:38, 14 June 2015
FileWriteBinary( <file>, <binary-array> )
Contents |
Description
Write the data from a binary variable to previously opened file at the current File Steam pointer location.
Parameters
file
A variable containing the File handle.
binary-array
The binary variable to write to the file.
Return Value
Success: Returns 1
Failure: Returns 0 if error occurs.
Remarks
You can set the File Steam pointer location with FileSeek( <file>, <offset>, <flag> ).
It would be silly to put an ASCII parameter on this function because YOU decide what the binary data contains.
Example
$a = Pack("A*", "Hello World!"); $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 { $zz = FileWriteBinary( $File, $a ); FileClose( $File ); }