Skip to content

fwrite_bytesFwriteBytesFwriteBytesfwrite_bytesT_fwrite_bytes🔗

Short description🔗

fwrite_bytesFwriteBytesFwriteBytesfwrite_bytesT_fwrite_bytes — Write bytes to a binary file.

Signature🔗

fwrite_bytes( file FileHandle, integer DataToWrite, out integer NumberOfBytesWritten )void FwriteBytes( const HTuple& FileHandle, const HTuple& DataToWrite, HTuple* NumberOfBytesWritten )static void HOperatorSet.FwriteBytes( HTuple fileHandle, HTuple dataToWrite, out HTuple numberOfBytesWritten )def fwrite_bytes( file_handle: HHandle, data_to_write: Sequence[int] ) -> int

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

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

int HFile.FwriteBytes( HTuple dataToWrite )

Description🔗

The operator fwrite_bytesFwriteBytes writes bytes to the output file defined by FileHandlefileHandlefile_handle. The output file must have been opened with open_fileOpenFile in binary format.

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

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

Execution information🔗

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🔗

FileHandlefileHandlefile_handle (input_control) file → (handle)HTuple (HHandle)HFile, HTuple (IntPtr)HHandleHtuple (handle)

File handle.

DataToWritedataToWritedata_to_write (input_control) integer-array → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Data to be written to the file.

NumberOfBytesWrittennumberOfBytesWrittennumber_of_bytes_written (output_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (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_bytesFwriteBytes returns 2 (H_MSG_TRUE). Otherwise, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

open_fileOpenFile

Possible successors

close_fileCloseFile

Alternatives

fwrite_stringFwriteString

See also

open_fileOpenFile, close_fileCloseFile, fread_bytesFreadBytes

Module🔗

Foundation