TURBO PASCAL

Новости

Программы   

Turbo Pascal 

Игры

Документация   

Странности

FAQ

Ссылки

Форум

Гостевая книга

Рассылка

Благодарности

Об авторе

54: How do I test whether a file is already open in a TP program?

 A: This question is best answered by providing the code:
  uses Dos;
  {... for non-text files ...}
  function ISFOPEN (var filePointer : file) : boolean;
  begin
    isfopen := FileRec(filePointer).mode <> FmClosed;
  end;
  {}
  {... for text files ...}
  function ISTOPEN (var filePointer : text) : boolean;
  begin
    istopen := TextRec(filePointer).mode <> FmClosed;
  end;
  {}
  procedure TEST;          { Testing a non-text file }
  const name = 'R:\TMP';
  var f  : file;
  begin
    Assign (f, name);
    writeln ('File ', name, ' is open is ', ISFOPEN(f));
    {$I-} rewrite (f); {$I+}
    if IOResult <> 0 then
      begin
        writeln ('Failed to open ', name);
        exit;
      end;
    writeln ('File ', name, ' is open is ', ISFOPEN(f));
    close(f);
    writeln ('File ', name, ' is open is ', ISFOPEN(f));
  end;
 

 Contents

На первую страницу

Rambler's Top100 Rambler's Top100
PROext: Top 1000

(с)Все права защищены

По всем интересующим вопросам прошу писать на электронный адрес

Hosted by uCoz