Operator Reference

fwrite_bytesT_fwrite_bytesFwriteBytesFwriteBytesfwrite_bytes (Operator)

fwrite_bytesT_fwrite_bytesFwriteBytesFwriteBytesfwrite_bytes — Write bytes to a binary file.

Signature

Herror T_fwrite_bytes(const Htuple FileHandle, const Htuple DataToWrite, Htuple* NumberOfBytesWritten)

void FwriteBytes(const HTuple& FileHandle, const HTuple& DataToWrite, HTuple* NumberOfBytesWritten)

Hlong HFile::FwriteBytes(const HTuple& DataToWrite) const

static void HOperatorSet.FwriteBytes(HTuple fileHandle, HTuple dataToWrite, out HTuple numberOfBytesWritten)

int HFile.FwriteBytes(HTuple dataToWrite)

def fwrite_bytes(file_handle: HHandle, data_to_write: Sequence[int]) -> int

Description

The operator fwrite_bytesfwrite_bytesFwriteBytesFwriteBytesfwrite_bytes writes bytes to the output file defined by FileHandleFileHandleFileHandlefileHandlefile_handle. The output file must have been opened with open_fileopen_fileOpenFileOpenFileopen_file in binary format.

The data to be written to the file is specified as DataToWriteDataToWriteDataToWritedataToWritedata_to_write.

The number of bytes that are written to the file is returned in NumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittennumberOfBytesWrittennumber_of_bytes_written.

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

FileHandleFileHandleFileHandlefileHandlefile_handle (input_control)  file HFile, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

File handle.

DataToWriteDataToWriteDataToWritedataToWritedata_to_write (input_control)  integer-array HTupleSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Data to be written to the file.

NumberOfBytesWrittenNumberOfBytesWrittenNumberOfBytesWrittennumberOfBytesWrittennumber_of_bytes_written (output_control)  integer HTupleintHTupleHtuple (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_bytesFwriteBytesFwriteBytesfwrite_bytes returns 2 ( H_MSG_TRUE) . Otherwise, an exception is raised.

Possible Predecessors

open_fileopen_fileOpenFileOpenFileopen_file

Possible Successors

close_fileclose_fileCloseFileCloseFileclose_file

Alternatives

fwrite_stringfwrite_stringFwriteStringFwriteStringfwrite_string

See also

open_fileopen_fileOpenFileOpenFileopen_file, close_fileclose_fileCloseFileCloseFileclose_file, fread_bytesfread_bytesFreadBytesFreadBytesfread_bytes

Module

Foundation