[comp.databases] Erasing file from Clipper application

dnb@fltk.UUCP (David Buonomo) (11/10/89)

I would like to erase a file from within a Clipper application and would
prefer not to use the "RUN" command to perform this at the DOS level.
Clipper does not like the following:

	filename = 'xyz' + str(num) + '.prn'
	erase file filename

		or

	filename = 'xyz' + str(num) + '.prn'
	erase file &filename

As you can see, the filename is not static, and I get a compile error on
both "erase file" statements.  Is there any way to erase a file whose name
is determined at run time.  Thanks, in advnace, for any help.

David Buonomo
301-984-1542

alexis@panix.UUCP (Alexis Rosen) (11/13/89)

In article <271@fltk.UUCP> dnb@fltk.UUCP (David Buonomo) writes:
>I would like to erase a file from within a Clipper application and would
>prefer not to use the "RUN" command to perform this at the DOS level.
>Clipper does not like the following:
>	filename = 'xyz' + str(num) + '.prn'
>	erase file filename           [David also tries macros]
>As you can see, the filename is not static, and I get a compile error on
>both "erase file" statements.  Is there any way to erase a file whose name
>is determined at run time.  Thanks, in advnace, for any help.

Well, it's been a while since I even looked at clipper, but doesn't it support
forced evaluation?  By the dBase spec, "erase file filename" looks for a file
named "filename.". In real dBase, the second code fragment would work (using
macros). But in clipper, to tell it you want erase file to take a variable
argument, you would write "erase file (filename)".

This syntax, BTW, is left over from dBase II, and is probably the ugliest
part of the entire language. FoxPro supports forced evaluation too, and it's
about time. I'm pretty sure dBase IV doesn't. No idea about dBIV 1.1.

Alexis Rosen
alexis@panix.uucp (but mail here isn't too good this week)
alexis@rascal.ics.utexas.edu

nfs0294@dsac.UUCP (Glendell R. Midkiff) (11/14/89)

From article <271@fltk.UUCP>, by dnb@fltk.UUCP (David Buonomo):
> I would like to erase a file from within a Clipper application and would
> prefer not to use the "RUN" command to perform this at the DOS level.

I use the following in my CLIPPER programs with no problem:

	DELETE FILE("&FILENAME")

FILENAME of course contains the name of the file to be deleted.
You can avoid the problem of DOS error FILE NOT FOUND by making a 
conditional delete:

	IF FILE("&FILENAME")
	  DELETE FILE("&FILENAME")
        ENDIF

Also, if you are trying to delete a database or index file, the file 
cannot be open.


D

D

-- 
 |-----------------------------------------------------------------------|
 |Glen Midkiff   osu-cis!dsacg1!gmidkiff                                 |
 |From the Internet: gmidkiff@dsac.dla.mil                               |
 |Phone: (614)-238-9643 @DLA, Systems Automation Center, Columbus, Oh.   |

jbrown@herron.uucp (Jordan Brown) (11/17/89)

In article <377@panix.UUCP>, alexis@panix.UUCP (Alexis Rosen) writes:
> In article <271@fltk.UUCP> dnb@fltk.UUCP (David Buonomo) writes:
> >	filename = 'xyz' + str(num) + '.prn'
> >	erase file filename           [David also tries macros]

There is no "erase file" command.  There are "delete file" and "erase",
which are synonyms.  This is his real problem.
-- 
Jordan Brown
jbrown@jato.jpl.nasa.gov