• Re: File processing (was Event loop and http::geturl)

    From Ralf Fassel@21:1/5 to All on Thu Jun 26 12:14:24 2025
    * Alan Grunwald <[email protected]>
    | My pseudo code is generally

    | while !eof {
    | read a line
    | if line is not empty
    | do stuff
    | endif
    | endwhile

    | I used to be puzzled why I needed the test for non-emptiness. I never
    | worked out why, nowadays I simply accept that's the way of things and
    | do it.

    If the read hits EOF, an empty line is returned which is not actually in
    the file. Depending on your data, this may or may not be a problem
    (if you're not interested in empty lines in the data, then no problem).

    Usually a better pattern for line-oriented data
    on a channel in blocking mode is

    while {[gets $fd line] >= 0} {
    # line has been read, possibly empty
    ...
    }
    close $fd

    HTH
    R'

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)