How can I execute the command delete file under HMG

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

How can I execute the command delete file under HMG

Post by fouednoomen »

Hi All Friends ,


I need to delete the old cdx files before re-indexing ,
How can I execute the command delete file under HMG

Regards

Foued
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: How can I execute the command delete file under HMG

Post by Pablo César »

Hi Foued,

You do the same way as have been done in Clipper or Harbour.
There are many ways like, but before I think is better to check if is existing file and second if file is accessable for delete. Because some time files are open (in low level) but not able for deleting. You can check if that file can be able for deleting.

You can use for deleting:

Code: Select all

Delete File("Name_File")
or

Code: Select all

      #include "fileio.ch"
      IF FErase( "test.txt" ) != F_ERROR
         ? "File successfully erased"
      ELSE
         ? "File can not be deleted"
      ENDIF
You can do a routine to check file condition by FOPEN. Please note it conditions table:
CA-Clipper Tools » Books 1-3 » Book2 » Disk Utilities » wrote:Table 7-11: Coding the File Attribute
-------------------------------------------
-------------------------------------------
if (nInfile := FOPEN(fileName, FO_READ+FO_EXCLUSIVE))<0
MsgStop("File cdx can not be deleted")
else
ferase(fileName)
Endif

I hope it has been clear for you. In case you have other dificulties, please return back with your questions.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
fouednoomen
Posts: 188
Joined: Sun Oct 14, 2012 8:33 am
DBs Used: DBF, MySQL, MariaDB, SQLite, PostgreSQL, Oracle, ODBC
Location: Tunisia

Re: How can I execute the command delete file under HMG

Post by fouednoomen »

Many Thanks My Friend
it's run

Foued
Post Reply