08-22-2005, 01:55 AM
Is there any way in FB/QB to test for the existence of a file, and have the program simply "move on" if it doesn't exist? That way the whole program doesn't crash from trying to interact with what doesn't exist.
Quote:Is there any way in FB/QB to test for the existence of a file, and have the program simply "move on" if it doesn't exist? That way the whole program doesn't crash from trying to interact with what doesn't exist.Simply "moving on" does not make any sense. What if the only input file to the program does not exist? Got no input, so "move on" to what?
Quote:Simply "moving on" does not make any sense. What if the only input file to the program does not exist? Got no input, so "move on" to what?Unlike you say, sometimes it is actually the best thing to do, to go on.
OPEN "asdd23.txt" FOR INPUT AS #1
IF ERR THEN PRINT "File not found. Aborting":SLEEP:END
PRINT "Okay"
SLEEP
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (not FALSE)
#endif
'':::::
function hFileExists( byval filename as string ) as integer static
dim f as integer
if opt.overwrite then
return FALSE
end if
f = freefile
if( open( filename, for input, as #f ) = 0 ) then
function = TRUE
close #f
else
function = FALSE
end if
end function
Quote:Neo,Moneo Wrote:Simply "moving on" does not make any sense. What if the only input file to the program does not exist? Got no input, so "move on" to what?Unlike you say, sometimes it is actually the best thing to do, to go on.
There are lots of examples to think of.
If DIR$(SomePath$+SomeFile$) <> "" Then Exist = 1