Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-03

quick question

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

r.w.h
begin
if exists ('bot.log')
then begin
assign(ftb,'bot.log');
append(ftb);
writeln(ftb,'bot log created'); // find away to enter time , date
close(ftb);
end
else
begin
assign(ftb,'bot.log');
reset(ftb);
writeln(ftb,'the botlog was created');
close(ftb);
end;
end;

whats wrong with the code.
i get the following error on compile.
botlog.pp(25,4) Error: Identifier not found "exists"

Rob Harris

Reply by email

James Mills
to r.w.h
r.w.h wrote 20 lines
begin if exists ('bot.log') then begin assign(ftb,'bot.log'); append(ftb); writeln(ftb,'bot log created'); // find away to enter time , date close(ftb); end else begin assign(ftb,'bot.log'); reset(ftb); writeln(ftb,'the botlog was created'); close(ftb); end; end; whats wrong with the code. i get the following error on compile. botlog.pp(25,4) Error: Identifier not found "exists"

Try: FileExists

cheers
James

- -ShortCircuit Services -URL: http://www.shortcircuit.net.au -WIKI: http://wiki.shortcircuit.net.au - -You need only two tools. WD-40 and duct tape. -If it doesn't move and it should, use WD-40. -If it moves and shouldn't, use the tape.

Reply by email

Jeff Pohlmeyer
program testbot;
uses dos;
function exists(const fn:string):boolean;
var
  f : text;
begin
  {$I-}
  if ( fn  '' ) then
  begin
    exists:=True;
    ioresult;
    assign(f, fn);
    reset(f);
    if ( ioresult = 0 ) then close(f) else exists:=False;
  end else exists:=False;
  {$I+}
end;
function NowStr:string;
  function pad(n:word):string; // nested function
  begin
    str(n, pad);
    if ( length(pad) < 2 ) then pad := '0' + pad;
  end;
var
  yr, mo, day, hr, min, sec, x : word;
begin
  GetDate(yr, mo, day, x);
  GetTime(hr, min, sec, x);
  NowStr := pad(yr) + '-' + pad(mo)  +'-' + pad(day) + ' ' +
            pad(hr) + ':' + pad(min) +':' + pad(sec);
end;
var
  ftb : text;
  botlog : string;
begin
   botlog := 'bot.log';
  assign(ftb, botlog);
  if exists(botlog) then append(ftb) else rewrite(ftb);
  writeln(ftb,'bot log created on ', NowStr);
  close(ftb);
end.

__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you�re looking for faster http://search.yahoo.com

Reply by email