Board index » delphi » Can anyone help me, please?

Can anyone help me, please?

Can anyone help me with this problem?

Using Turbo Pascal for Windoze 1.5 I am trying to check if a file exists
when a user enters a 8.3 filename.

If the file does not exist I am trying to trap this and tell the user,
but whichever way I try to trap it, I just get a Run-Time error 2 and
cannot proceed.

Any help would be appreciated.

this is the part of the program I am struggling with:-

repeat
        write('Enter the filename : ');
        readln(Filename);
        FileExists(Filename);
        if FileExists(Filename) = False then
                writeln('Error - the file does not exist')
until True;

_______________________________________
Space IS dangerous ...
         especially the space between our ears!

To contact by email, please remove the nospam. in the address

 

Re:Can anyone help me, please?


Quote
John wrote:

> Can anyone help me with this problem?

> Using Turbo Pascal for Windoze 1.5 I am trying to check if a file exists
> when a user enters a 8.3 filename.

> repeat
>         write('Enter the filename : ');
>         readln(Filename);
>{$I-}

          assign(f,Filename);reset(f);
Quote
>         FileExists:=ioresult=0;

          if not FileExists then
Quote
>                 writeln('Error - the file does not exist')
> {$I+}
  until FileExists;

just look in the help files for more details on {$ commands
--
Rommert J. Casimir
Tilburg University, Room B435, tel 31 13 4662016
P.O. Box 90153, 5000LE Tilburg, The Netherlands
http://cwis.kub.nl/~few/few/BIKA/rc_home.htm

Re:Can anyone help me, please?


JRS:  In article <MPG.f254a1da0aad23989...@news.rmplc.co.uk> of Tue, 13
Jan 1998 09:54:08 in comp.lang.pascal.borland, John

Quote
<bjro...@nospam.rmplc.co.uk> wrote:

>Using Turbo Pascal for Windoze 1.5 I am trying to check if a file exists
>when a user enters a 8.3 filename.

>If the file does not exist I am trying to trap this and tell the user,
>but whichever way I try to trap it, I just get a Run-Time error 2 and
>cannot proceed.

>Any help would be appreciated.

>this is the part of the program I am struggling with:-

>repeat
>       write('Enter the filename : ');
>       readln(Filename);
>       FileExists(Filename);
>       if FileExists(Filename) = False then
>               writeln('Error - the file does not exist')
>until True;

repeat ... until True  is not useful.
For if ... = false , use  if not ... .
You might find my Pascal Web pages useful.
See   http://www.merlyn.demon.co.uk/programs/chk_xist.pas
--
John Stockton, Surrey, UK.    j...@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web <URL: http://www.merlyn.demon.co.uk/> - TP/BP/&c. FAQqish topics & links.
  Timo's TurboPascal <A HREF="ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip">FAQ</A>.
  <A HREF="http://www.merlyn.demon.co.uk/clpb-faq.txt">Mini-FAQ</A> of c.l.p.b.

Re:Can anyone help me, please?


On 1998-01-13 bjro...@nospam.rmplc.co.uk(John) said:
   >Using Turbo Pascal for Windoze 1.5 I am trying to check if a file
   >exists when a user enters a 8.3 filename.
   >If the file does not exist I am trying to trap this and tell the
   >user, but whichever way I try to trap it, I just get a Run-Time
   >error 2 and cannot proceed.
   >Any help would be appreciated.
|
This is a short but functional solution.
function exist(fn : string) : boolean;
begin
  exist:=fsearch(fn,'')<>'';
end;
|
exist=true if the file exists and false if it doesn't.
Jay

jaywa...@gte.net

"Energize," said Kirk, and the pink bunny appeared.

Net-Tamer V 1.10.1  - Test Drive

Re:Can anyone help me, please?


Re:Can anyone help me, please?


Hi guys.I am in Grade 11,using TP 7 and have to do a MAJOR  PROJECT this
year.I am trying to put pictures into my program but have failed in doing
so:The techno-rich words confused me.

I would also like to know if anyone has any good ideas for a project.

Thanks :-))

Other Threads