- FileSelectDialog
- FileFindFirst
- FileFindNext
- FileFindClose
- FileIsExist
- FileOpen
- FileClose
- FileCopy
- FileDelete
- FileMove
- FileFlush
- FileGetInteger
- FileIsEnding
- FileIsLineEnding
- FileRead
- FileReadArray
- FileReadBool
- FileReadDatetime
- FileReadDouble
- FileReadFloat
- FileReadInteger
- FileReadLong
- FileReadNumber
- FileReadString
- FileReadStruct
- FileReadComplexDouble
- FileReadComplexFloat
- FileSeek
- FileSize
- FileTell
- FileWrite
- FileWriteArray
- FileWriteComplexDouble
- FileWriteComplexFloat
- FileWriteDouble
- FileWriteFloat
- FileWriteInteger
- FileWriteLong
- FileWriteString
- FileWriteStruct
- FileLoad
- FileSave
- FolderCreate
- FolderDelete
- FolderClean
FileReadInteger
Reads an int, short or char value from a binary file depending on the specified length in bytes. Reading starts from the current position of the file pointer.
Reads a string from a CSV file from the current position to the delimiter (or to the end of a text line) and converts the read string to a value of type int, short or char depending on the specified length in bytes.
int FileReadInteger(
|
Parameters
file_handle
[in] File descriptor returned by FileOpen().
size=INT_VALUE
[in] Number of bytes (up to 4 inclusive) that should be read. The corresponding constants are provided: CHAR_VALUE = 1, SHORT_VALUE = 2 and INT_VALUE = 4, so the function can read the whole value of char, short or int type.
Return Value
A value of the int type. The result of this function must be explicitly cast to a target type, i.e. to the type of data that you need to read. Since a value of the int type is returned, it can be easily converted to any integer value. The file pointer is shifted by the number of bytes read.
Equivalent to calling FileRead with a parameter of type char, short or int. To reliably read uint data, use FileRead with the corresponding parameter.
char char_value;
|
Note
To get information about an error, call GetLastError().
When reading less than 4 bytes, the received result is always positive. If one or two bytes are read, the sign of the number can be determined by explicit casting to type char (1 byte) or short (2 bytes). Getting the sign for a three-byte number is not trivial, since there is no corresponding underlying type.
Example (the file obtained after executing the example for FileWriteInteger function is used here)
//+------------------------------------------------------------------+
|
See also
IntegerToString, StringToInteger, Integer types, FileWriteInteger