[comp.lang.pascal] TP-HELP?

c1s@psuecl.bitnet (12/16/89)

        I was hoping someone could explain the odd behavior of a
seemingly simple procedure:

  function GetAChar: char;
  begin
    if not eof(ProgFile)
       then begin
              read(ProgFile,LastChar);
              GetAChar := LastChar;
            end
       else GetAChar := #255;
  end; { GetAChar }

  where ProgFile is a global Text file, and LastChar is a global
variable of type Char.  My problem is, for no particular reason,
the function repeats itself several times at one point, and
gets into an infinite loop at another.  Using TP5.5 and single
stepping through the function, execution will reach the final
end statement and immediately jump back to the first begin.
According to the call stack, there is only one call to this
function which seemingly refuses to end.  As this function works
95% of the time, I am at a loss to understand what is going on
the few times it refuses to work.  Perhaps someone out there
has an idea -- could something else in my program be affecting
this?  Thanks in advance!
           Chris Stone
               C1S@ECL.PSU.EDU