fwrite_stringT_fwrite_stringFwriteStringFwriteStringfwrite_string (算子)
名称
fwrite_stringT_fwrite_stringFwriteStringFwriteStringfwrite_string — 将字符串和数字写入文本文件。
签名
def fwrite_string(file_handle: HHandle, string: MaybeSequence[Union[int, float, str]]) -> None
描述
算子 fwrite_stringfwrite_stringFwriteStringFwriteStringFwriteStringfwrite_string writes one or more strings or numbers
to the output file defined by the handle FileHandleFileHandleFileHandleFileHandlefileHandlefile_handle.
The output file must have been opened with open_fileopen_fileOpenFileOpenFileOpenFileopen_file in text format.
Strings and numbers that are to be written into the file are passed via the
input parameter StringStringStringStringstringValstring to the operator fwrite_stringfwrite_stringFwriteStringFwriteStringFwriteStringfwrite_string.
The parameter StringStringStringStringstringValstring 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.
算子 fwrite_stringfwrite_stringFwriteStringFwriteStringFwriteStringfwrite_string 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""locale_encoding""locale_encoding""locale_encoding""locale_encoding" and the current encoding of the HALCON library is
'utf8'"utf8""utf8""utf8""utf8""utf8" (see set_system(::'filename_encoding','utf8':)set_system("filename_encoding","utf8")SetSystem("filename_encoding","utf8")SetSystem("filename_encoding","utf8")SetSystem("filename_encoding","utf8")set_system("filename_encoding","utf8")).
The call set_system(::'flush_file', <boolean-value>:)set_system("flush_file", <boolean-value>)SetSystem("flush_file", <boolean-value>)SetSystem("flush_file", <boolean-value>)SetSystem("flush_file", <boolean-value>)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""flush_file""flush_file""flush_file""flush_file" is set to 'false'"false""false""false""false""false", the characters
(especially in case of screen output) show up only after the operator
fnew_linefnew_lineFnewLineFnewLineFnewLinefnew_line is called.
执行信息
- 多线程类型:可重入(与非独占算子并行运行)。
- 多线程作用域:全局(可从任何线程调用)。
- 未采用并行化处理。
参数
FileHandleFileHandleFileHandleFileHandlefileHandlefile_handle (输入控制) file → HFile, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
File handle.
StringStringStringStringstringValstring (输入控制) string(-array) → HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)
Values to be written into the file.
默认值:
'hallo'
"hallo"
"hallo"
"hallo"
"hallo"
"hallo"
示例(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);
示例(HDevelop)
fwrite_string(FileHandle,['text with numbers:',5,' and ',1.0])
* results in the following output:
* 'text with numbers:5 and 1.00000'
示例(HDevelop)
fwrite_string(FileHandle,['text with numbers:',5,' and ',1.0])
* results in the following output:
* 'text with numbers:5 and 1.00000'
示例(HDevelop)
fwrite_string(FileHandle,['text with numbers:',5,' and ',1.0])
* results in the following output:
* 'text with numbers:5 and 1.00000'
结果
If the writing procedure was carried out
successfully, the operator fwrite_stringfwrite_stringFwriteStringFwriteStringFwriteStringfwrite_string 返回值 2 ( H_MSG_TRUE )。否则,将抛出异常。
Encoding errors have no influence on the result state.
可能的前趋
open_fileopen_fileOpenFileOpenFileOpenFileopen_file
可能的后继
close_fileclose_fileCloseFileCloseFileCloseFileclose_file
替代
write_stringwrite_stringWriteStringWriteStringWriteStringwrite_string
另见
open_fileopen_fileOpenFileOpenFileOpenFileopen_file,
close_fileclose_fileCloseFileCloseFileCloseFileclose_file,
set_systemset_systemSetSystemSetSystemSetSystemset_system
模块
基础