function getline()
You have a text stream and want to process the lines
Read the stream into the string t_t_str. Define the start of the string in t_t_pos and the length of the string in t_t_end. The function getline() will return the line starting at t_t_pos without crlf (= CarriageReturn, LineFeed; =chr(13) + chr(10); in C "\r\n") and position t_t_pos to the start of the next line. Hence, you need not take care of this index.
The function will also realize chr(10) as end of line if chr(13) is omitted.
If no chr(10) is found in a string, the string is returned and t_t_pos is set on the end of the string
Please understand that t_t_str is not shortended to the rest af the string after finding the marker (chr(13) and or chr(10))!
Compare with get2semi().
***************************** | |
* Tool&Task example program * | |
* getline() * | |
* last compile: 16.03.2018 * | |
***************************** |
tt_hr = tt_open_file(gUserDataTT + "temp\myfile.txt") | |
if tt_hs = -1 |
&& if file does not exist |
return | |
endif | |
t_t_end = fseek(tt_hr, 0, 2) |
&& length of file |
fseek(tt_hr, 0, 0) |
&& back to top |
t_t_str = fread(t_t_hr, t_t_end) |
&& read file into string |
tt_close_file(tt_hr) |
&& close file |
t_t_pos = 1 |
&& position to start of file |
do while t_t_pos < t_t_end |
&& all the lines of file |
tt = getline() |
&& into tt |
*... |
&& process each line |
enddo | |
return |