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 - appendext() append extension to a file name http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 appendext()         Append extension to a file name
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func char appendext extern
   param const char    cExtension, ;
         const char    cFileName, ;
         value logical lReplace

 Arguments
   cExtension is the default file name extension.

   cFileName is the file name for appending the extension.

   lReplace indicates if the extension must be replaced even
   if cFileName has an extension.

 Return
   The full filename with extension appended.

 Description
   The appendext() function appends a default extension to a file name.

   The lReplace parameter controls if the extension is to be replaced
   independently of the presence of an extension in cFileName. When lReplace
   is set to .t., the extension is replaced. When lReplace is set to .f.,
   the new extension is only added if cFileName does not have its own
   extension.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_appendext
   ? appendext( "txt", "test", .f. )            // prints "test.txt"
   ? appendext( "txt", "test", .t. )            // prints "test.txt"
   ? appendext( "txt", "c:\src\test.prg", .f. ) // prints "c:\src\test.prg"
   ? appendext( "txt", "c:\src\test.prg", .t. ) // prints "c:\src\test.txt"
   ? appendext( "prg", ".\test", .f. )          // prints "c:\src\test.prg"
   ? appendext( "prg", ".\test", .t. )          // prints "c:\src\test.prg"
   ? appendext( "prg", "..\test.txt", .f. )     // prints "c:\src\test.txt"
   ? appendext( "prg", "..\test.txt", .t. )     // prints "c:\src\test.prg"
   endproc

   proc main
   Test_appendext()
   endproc

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