Re: How check for "path/file exists"?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Nevermind, I found it, sigh.  Tested for a file that *does* exist, so it
then tried to open file that *doesn't*, which failed. argh.

Dan


----- Original Message -----
From: "Dan B Moyer" <DANMOYER at prodigy.net>
To: "Euphoria Programming for MS-DOS" <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Sunday, September 03, 2000 9:29 PM
Subject: Re: How check for "path/file exists"?


> Kat,
>
> Tried it, but when no file exists, I get a dos window with message "can't
> open" filename instead of going on through the if-then.
>
> Here's what I wrote:
>
> --<code>
> integer filethere
>
> filethere = open("c:\\Euphoria\\Win32Lib\\A new Tutorial\\Tutor3.exw","r")
> if filethere != -1 then  -- is a file there
>     close(filethere)
>     Jump_to(
>     -- passing YOUR main window's id:
>     MainWindow,
>     -- with the program to call:
>     "exw.exe",
>     -- this is MY current 'tutorials' default path !!
>     "c:\\Euphoria\\Win32Lib\\A new Tutorial\\",
>     -- the parameter to pass to exw.exe:
>     "xTutor3.exw",  -- for purpose of test, there is no such file
>     -- and last, the 'show' parameter:
>     SW_SHOWDEFAULT )
> else
>
> end if
> <code ends>
>
> Dan
>
> ----- Original Message -----
> From: "Kat" <gertie at PELL.NET>
> To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
> Sent: Sunday, September 03, 2000 8:35 PM
> Subject: Re: How check for "path/file exists"?
>
>
> > On 3 Sep 2000, at 19:13, Dan B Moyer wrote:
> >
> > > Wolf, all,
> > >
> > > How can I check for whether a specified "path/file" exists??
> > >
> > > I'm trying to use Wolf's "jumpto" (or perhaps his "ShellExecute2") to
> run
> > > another program from within my program (to jump to it); when this is a
> > > program with a "stable" path, no problem.  But I'm wanting to be able
to
> > > jump to Wolf's tutorial, which isn't always at a known place in the
> Euphoria
> > > folder, so I need to be able to *test* for whether the path/file I
> > > tentatively specify actually exists or not, so I can activate the
"open
> > > file" dialog if it doesn't.
> > >
> > > I changed Wolf's "jumpto" to a function, thinking to use the return as
a
> > > test, but while it worked if the path was correct, when the path/file
> wasn't
> > > correct it just bombed & output an error message about "can't open
> file".
> > >
> > > Any thoughts?
> >
> > Try opening the file for a read before you try to exec it. If it cannot
be
> opened, then it's
> > not there or it's locked,, either way, you can't run it.
> >
> > Kat
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu