Skip to content

fwrite_stringFwriteStringFwriteStringfwrite_stringT_fwrite_string🔗

Short description🔗

fwrite_stringFwriteStringFwriteStringfwrite_stringT_fwrite_string — Write strings and numbers into a text file.

Signature🔗

fwrite_string( file FileHandle, string String )void FwriteString( const HTuple& FileHandle, const HTuple& String )static void HOperatorSet.FwriteString( HTuple fileHandle, HTuple stringVal )def fwrite_string( file_handle: HHandle, string: MaybeSequence[Union[int, float, str]] ) -> None

Herror T_fwrite_string( const Htuple FileHandle, const Htuple String )

void HFile::FwriteString( const HTuple& String ) const

void HFile::FwriteString( const HString& String ) const

void HFile::FwriteString( const char* String ) const

void HFile::FwriteString( const wchar_t* String ) const (Windows only)

void HFile.FwriteString( HTuple stringVal )

void HFile.FwriteString( string stringVal )

Description🔗

The operator fwrite_stringFwriteString writes one or more strings or numbers to the output file defined by the handle FileHandlefileHandlefile_handle. The output file must have been opened with open_fileOpenFile in text format.

Strings and numbers that are to be written into the file are passed via the input parameter StringstringValstring to the operator fwrite_stringFwriteString. The parameter StringstringValstring accepts also tuples where strings and numbers are mixed. All elements of the tuple are written consecutively into the file without blanks or other separators in between. Numbers are converted into a string before they are written.

The operator fwrite_stringFwriteString emits a low-level error message, when the string cannot be transcoded without loss of information into the specified file encoding. This can only happen when the file encoding is 'locale_encoding'"locale_encoding" and the current encoding of the HALCON library is 'utf8'"utf8" (see set_system(::'filename_encoding','utf8':)).

The call set_system(::'flush_file', <boolean-value>:) determines whether the output characters are immediately written to the file or not. If the value 'flush_file'"flush_file" is set to 'false'"false", the characters (especially in case of screen output) show up only after the operator fnew_lineFnewLine is called.

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.

StringstringValstring (input_control) string(-array) → (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)MaybeSequence[Union[int, float, str]]Htuple (char* / Hlong / double)

Values to be written into the file.

Default: 'hallo'"hallo"

Example🔗

(HDevelop)

fwrite_string(FileHandle,['text with numbers:',5,' and ',1.0])
* results in the following output:
* 'text with numbers:5 and 1.00000'
(C)
   fwrite_string(FileHandle,"text with numbers: ")\;
   fwrite_string(FileHandle,"5")\;
   fwrite_string(FileHandle," and ")\;
   fwrite_string(FileHandle,"1.0")\;
/* results in the following output:       */
/*    'text with numbers: 5 and 1.00000'   */

/* Tupel Version */
  int  i\;
  double d\;
  Htuple Tuple\;
 create_tuple(&Tuple,4)\;
  i = 5\;
  d = 10.0\;
  set_s(Tuple,"text with numbers: ",0)\;
  set_i(Tuple,i,1)\;
  set_s(Tuple," and ",2)\;
  set_d(Tuple,d,3)\;
  T_fwrite_string(FileHandle,HilfsTuple)\;

Result🔗

If the writing procedure was carried out successfully, the operator fwrite_stringFwriteString returns the value 2 (H_MSG_TRUE). Otherwise, an exception is raised. Encoding errors have no influence on the result state.

Combinations with other operators🔗

Combinations

Possible predecessors

open_fileOpenFile

Possible successors

close_fileCloseFile

Alternatives

write_stringWriteString

See also

open_fileOpenFile, close_fileCloseFile, set_systemSetSystem

Module🔗

Foundation