\(\text{FileWriteInteger}\)¶
You can use the \(\text{FileWriteInteger}\) function to write an integer to a file.
You can use the \filewriteinteger
backslash command to insert this function.
The following variants of this function are available:
\(\text{boolean } \text{FileWriteInteger} \left ( \text{<file number>}, \text{<integer value>} \right )\)
\(\text{boolean } \text{FileWriteInteger} \left ( \text{<file number>}, \text{<integer value>}, \text{<size/endian>} \right )\)
The \(\text{<file number>}\) parameter is an integer value returned by the \(\text{FileOpenWrite}\) or \(\text{FileOpenWriteTruncate}\) functions. The \(\text{<integer value>}\) parameter holds the integer value to be written. The \(\text{<size/endian>}\) parameter can be used to specify how the integer value should be written.
If the \(\text{<size/endian>}\) parameter is excluded or if the \(\text{size/endian}\) parameter is zero, the function will write the integer value as a decimal string.
If the \(\text{<size/endian>}\) parameter is greater than zero, the \(\text{FileWriteInteger}\) will write the integer in binary little-endian format, using as many bytes as is specified by the \(\text{<size/endian>}\).
If the \(\text{<size/endian>}\) parameter is negative, the \(\text{FileWriteInteger}\) will write the integer in binary big-endian format, using as many bytes as is specified by the \(\text{<size/endian>}\).
For details of the little-endian and big-endian format, see FileReadInteger.
The \(\text{FileWriteInteger}\) function returns true
on success or
false
on failure.
The Figure 137 shows how you can use the \(\text{FileReadInteger}\) function.