fwrite_bytesT_fwrite_bytesFwriteBytesFwriteBytes (Operator)
Name
fwrite_bytesT_fwrite_bytesFwriteBytesFwriteBytes
— Write bytes to a binary file.
Signature
Description
The operator fwrite_bytesfwrite_bytesFwriteBytesFwriteBytesFwriteBytes
writes bytes to the output
file defined by FileHandleFileHandleFileHandleFileHandlefileHandle
.
The output file must have been opened with open_fileopen_fileOpenFileOpenFileOpenFile
in
binary format.
The data to be written to the file is specified as DataToWriteDataToWriteDataToWriteDataToWritedataToWrite
.
The number of bytes that are written to the file is returned in
NumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittennumberOfBytesWritten
.
Execution Information
- Multithreading type: reentrant (runs in parallel with non-exclusive operators).
- Multithreading scope: global (may be called from any thread).
- Processed without parallelization.
Parameters
FileHandleFileHandleFileHandleFileHandlefileHandle
(input_control) file →
HFile, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
File handle.
DataToWriteDataToWriteDataToWriteDataToWritedataToWrite
(input_control) integer-array →
HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Data to be written to the file.
NumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittennumberOfBytesWritten
(output_control) integer →
HTupleHTupleHtuple (integer) (int / long) (Hlong) (Hlong)
Number of bytes written to the output
binary file.
Example (HDevelop)
* Write a binary file byte by byte.
open_file (Filename, 'append_binary', FileHandle)
fwrite_bytes(FileHandle, [0x97, 99, 102], BytesWritten)
close_file (FileHandle)
Result
If an output file is open in binary mode and no file write error occurs,
the operator fwrite_bytesfwrite_bytesFwriteBytesFwriteBytesFwriteBytes
returns 2 (H_MSG_TRUE). Otherwise, an exception is
raised.
Possible Predecessors
open_fileopen_fileOpenFileOpenFileOpenFile
Possible Successors
close_fileclose_fileCloseFileCloseFileCloseFile
Alternatives
fwrite_stringfwrite_stringFwriteStringFwriteStringFwriteString
See also
open_fileopen_fileOpenFileOpenFileOpenFile
,
close_fileclose_fileCloseFileCloseFileCloseFile
,
fread_bytesfread_bytesFreadBytesFreadBytesFreadBytes
Module
Foundation