function get2semi()
You have a SDF (Semicolon divided fields) file as data source. Each line is ended with crlf (see getline().
Read the lines into the variable t_t_semi. Use get2semi to return the left string up tho the last char before the next semicolon. Afterwards, t_t_semi begins with the first char after the semicolon just found.
If no semicolon is found, t_t_semi is retuned. In this case t_t_semi is an empty string and following calls to get2semi will return blank.
A semicolon sequenced by a semicolon has an empty string in between. The value of it would be 0 and the logical value .f. (compare with example)
***************************** | |
* Tool&Task example program * | |
* get2semi() * | |
* last compile: 24.11.2021 * | |
***************************** |
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 |
t_t_semi = getline() |
&& line into t_t_semi |
vari1 = get2semi() |
&& a string |
vari2 = get2semi() |
&& second string |
vari3 = val(get2semi()) |
&& assume it is a number |
vari4 = 'T'==get2semi() |
&& where .t. is coded as character 'T' |
enddo | |
return |