Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - erase delete a file http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 erase               Delete a file
------------------------------------------------------------------------------
 Syntax
   erase cFileName

 Arguments
   cFileName is the name of the file to delete.

 Description
   The erase command erases the specified file. cFileName may contain drive
   and directory spcifications, but no wildcard
   characters like "*", or "?".

   Make sure that files you want to delete are closed prior to calling erase.
   If you try to erase a non-existing file, run-time error 2 will be issued
   (file not found). Use the exist() function prior to calling erase or use
   the del() function instead of the erase command.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   proc Test_erase
   vardef
      char cFileName
   enddef
   cFileName := "\"                             // create in current directory
   if createtempfile( cFileName )               // create temporary file
      if exist( cFileName )                     // check if file exists
         ? "Temporary file", cFileName, "created"
         erase( cFileName )                     // delete temporary file
         if .not. exist( cFileName )            // check if file exists
            ? "Temporary file deleted"
         else
            ? "Could not delete file " + cFileName
         endif
      else
         ? "Temporary file disappeared <g>"
      endif
   else
      ? "File creation failed"
   endif
   endproc

   proc main
   Test_erase()
   endproc

See Also: del()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson