Detecting file existance

Detecting file existance

Post by Dennis Drew Mosel » Wed, 16 Mar 1994 01:00:25



Hello,

I need to be able to detect if a file exists.  At some point in my script,
I want to save a record to a file.  If a file by that name exists, I want
to automatically overwrite (or perhaps provide a dialogue to the user), but
if it doesn't exists I don't want to do anything special.

The problem is that Paradox will prompt to overwrite or cancel, and I need
to know if I need to answer that prompt.

Any help will be greatly appreciated.

Thanks,

Drew Moseley

 
 
 

Detecting file existance

Post by Ken Ostr » Wed, 16 Mar 1994 06:38:55



Quote:>Hello,
>I need to be able to detect if a file exists.  At some point in my script,
>I want to save a record to a file.  If a file by that name exists, I want
>to automatically overwrite (or perhaps provide a dialogue to the user), but
>if it doesn't exists I don't want to do anything special.
>The problem is that Paradox will prompt to overwrite or cancel, and I need
>to know if I need to answer that prompt.
>Any help will be greatly appreciated.
>Thanks,

Look under fileSystem : there is a function called isFile()

if isFile("myfile") then
        dosomething
endif

--
                    Limax Computing - Paradox Questions?


          Phone: (408) 425-7455   Fax: (408) 425-7516

 
 
 

Detecting file existance

Post by Lance Leona » Wed, 16 Mar 1994 09:54:14




>Subject: Detecting file existance
>Date: 14 Mar 1994 16:00:25 GMT

Drew,

Quote:>I need to be able to detect if a file exists.  At some point in my script,
>I want to save a record to a file.  If a file by that name exists, I want
>to automatically overwrite (or perhaps provide a dialogue to the user), but
>if it doesn't exists I don't want to do anything special.

Depends on what you're using to create the disk file.  Most ObjectPAL
operations will replace an existing file without confirmation, unlike the UI
equivelant operations.  For example, COPY( "TABLE1", "TABLE2") will replace
Table2 if it already exists.

To answer your question, you can use IsFile() (a Table procedure) to see
whether or not a disk file exists.  For example:

   isFile("C:\\WINDOWS\\WIN.COM")

should return True.  To delete a disk file before performing your operation,
use the FileSystem Delete() method.  For example

   var
      fs FileSystem
   endVar

   if isFile("C:\\DIRNAME\\FILENAME") then
      fs.delete("C:\\DIRNAME\\FILENAME")
   endIf

Again, most ObjectPAL methods and procedures that create files will overwrite
older files without confirmation.  You might see if there's an appropriate
ObjectPAL method or procedure for the operation you're trying to perform.

Hope this helps...

----------------------------------------------------------------

----------------------------------------------------------------
"No, I'm not a Borland rep and I don't know any unreleased info"
----------------------------------------------------------------

 
 
 

Detecting file existance

Post by Wilhelm Sarasa » Wed, 16 Mar 1994 17:18:49



: Hello,

: I need to be able to detect if a file exists.  At some point in my script,
: I want to save a record to a file.  If a file by that name exists, I want
: to automatically overwrite (or perhaps provide a dialogue to the user), but
: if it doesn't exists I don't want to do anything special.

: The problem is that Paradox will prompt to overwrite or cancel, and I need
: to know if I need to answer that prompt.

If you are using the windows version you can try findFirst out of
the FileSystem. There is a findFirst in DOS, too, so the DOS version, if
that is what you use, may have something similar.


Have Fun!                                                          Wilhelm

 
 
 

Detecting file existance

Post by Newmarch, JE, John, Head of U » Thu, 17 Mar 1994 20:41:21




>Subject: Detecting file existance
>Date: 14 Mar 1994 16:00:25 GMT
>Hello,
>I need to be able to detect if a file exists.  At some point in my script,
>I want to save a record to a file.  If a file by that name exists, I want
>to automatically overwrite (or perhaps provide a dialogue to the user), but
>if it doesn't exists I don't want to do anything special.
>The problem is that Paradox will prompt to overwrite or cancel, and I need
>to know if I need to answer that prompt.
>Any help will be greatly appreciated.
>Thanks,
>Drew Moseley

The funcion MENUCHOICE() is the key to this.

John

-------------------------------------------------------------------------------
John Newmarch                               Pmail (local): its/jen

University of Cape Town                         Telephone: (27-21) 650-3031
7700 Rondebosch                                       Fax: (27-21) 650-3726
Republic of South Africa

 
 
 

1. Proper way of detecting an objects existance

Since I started using SQL I've been using this code to drop/create stored
procedures and tables:

if exists(select * from sysobjects where name = 'ZZZZZ' and type = 'X')
    drop procedure/table ZZZZZ

create procedure/table ZZZZZ as

blah...blah

I took this code from the generated scripts that SQL creates. However, after
reading here and thinking about the general rule of not using system tables
directly, I'm wondering what the recommended way is? Can someone post a
snipet of code of how I *should* be doing this? Thanks.

--
Zachary Wells
All In One
MIS Department

2. em question

3. detecting existance of global temporary table in 6.5

4. REPORT-WRITER-PROBLEM6.4

5. Detect Field existance

6. Shrink DB

7. Detecting the existance of a directory in FoxPro 2.6

8. Help! What's wrong?

9. Testing the existance and size of a file

10. BULK-INSERT File existance checking

11. sql Server agent - jobstep to check for existance of a file

12. Checking for a file's existance

13. API to automatically flag the existance of a file in a directory