Text File Functions
- General
- Additional notes
- Name
- Directory
- Reset
- Definition of states
Count lines
Read line
Write line
Additional notes
Writing and reading a line from a text file is always accomplished according to the scheme:
- Check if the directory is available
- Open the file
- writing or reading or counting the row(s)
- Close the file.
Writing and reading is done as long as the input bWrite or bRead a HIGH signal.
The lines are internally terminated with 0x0D and 0x0A when writing.
The lines are read starting from the specified line number for as long as a 0x0A is found. A previous 0x0D as well as the 0X0A will not be output.
Writing in large files or reading from large files or counting may take a longer period of time (increasing with the size of the file).
More:
Name
- The file name can have up to 17 characters
- If the information about directory + name is shorter than 18 characters, it can be dispensed to the input of the path. For example, Test/file.txt as name creates a subdirectory in which the file is stored.
- Windows
For all information no upper/lower case is considered
- Q.station
For all information, the upper/lower case is considered
Directory
Windows
- For all information no upper/lower case is considered
- as a separator "\" are provided
- if no directory is specified, the file will be created or read in the directory "File Services"
Q.station
- For all information, the upper/lower case is considered
- as a separator "\" are provided
- if no directory is specified, the file will be created or read in „/home/user1/fs/online/“ (is not recommended)
- recommendation:
- specify the device index
- e.g.:
* hd0 – using internal directory
* sd0 – using sd c- card
* etc.
Reset
If at the input bReset a HIGH signal applied:
- an already existing file will be restarted from the beginning (overwritten)
- a new file is started, if the name or directory has been changed in between.
Definition of states
Value | Comment |
---|---|
0 | No error or message |
1 | No valid name or name not defined |
2 | No valid directory |
3 | Incorrect or non-connected data input |
4 | Error in determining the storage location of the file |
5 | Error opening file |
6 | Error writing to the file |
7 | Error reading from file |
8 | Error in the provision of the memory for the data output |
9 | Line too long or missing end of line (0x0A) |