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 - exist() test if a file exists http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 exist()             Test if a file exists
------------------------------------------------------------------------------
 Declaration
   file.hdr

 Syntax
   func logical exist extern
   param const char cFileName

 Arguments
   cFileName is the name of the file to test.

 Return
   A logical indicating if the specified file exists. For subdirectory and
   volume label names .f. is returned.

 Description
   The exist() function returns .t. if the specified file exists. This
   function is identical to the dBase function file(). Because in Force the
   token file is a reserved keyword for a data type, it is necessary to
   use a different symbol name for this function.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   dbfdef sNames
      char( 10 ) name
   enddef
   
   proc Test_exist
   vardef
      char cFile
   enddef
   cFile := "names.dbf"
   // verify existence of a database file before using it
   if .not. exist( cFile )
      ? "Creating database"
      build cFile from alias sNames
   endif
   if exist( cFile )
      ? "Database created"
      open cFile alias sNames
   endif
   close sNames
   erase cFile
   if exist( cFile )
      ? "Clean up failed"
   endif
   endproc

   proc main
   Test_exist()
   endproc

See Also: findfirst()

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