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 - ren() change the name of a file http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 ren()               Change the name of a file
------------------------------------------------------------------------------
 Declaration
   file.hdr

 Syntax
   proc ren extern
   param const char cNewFileName, ;
         const char cOldFileName

 Arguments
   cNewFileName is the target file name.
   cOldFileName is the source file name.

 Return
   None.

 Description
   The ren() function renames a file. The function operates identically to
   the rename command. A runtime error occurs if the source file does not
   exist.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   proc Test_ren
   vardef
      char cOld, cNew
   enddef
   cOld := "test.txt"
   cNew := "newname.txt"
   set alternate to cOld
   set alternate on                                // create file
   ? "Testing the ren() function"
   close alternate
   if exist( cOld ) .and. .not. exist( cNew )
      ren( cNew, cOld )                            // rename file
      if .not. exist( cOld ) .and. exist( cNew )
         ? "Rename successful"
         del( cNew )                               // clean up
      endif
   endif
   endproc

   proc main
   Test_ren()
   endproc

See Also: rename

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