Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stonefield Database Dictionary - Going Forward
Message
From
28/09/2006 11:25:52
 
 
To
28/09/2006 03:04:19
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01156596
Message ID:
01157864
Views:
21
>pardon me for jumping in. Your code show why I NEVER use the file() function, because it is simply a dangerous function to use. Even if you specify a directory, it always checks in all the directories which is specified in set path to. So file('c:\test\yourfile.ext') will show true even if there is no c:\test\yourfile.exe on your HD, as long as you have a file called yourfile.ext in your VFP path.

PMFJI, but that is not true. If you specify a path and the file is not present, FILE() returns false as the following code demonstrates.
LOCAL lcCurDir
lcCurDir = SYS(5) + SYS(2003)

* Assumes you have directory C:\temp
CD c:\temp
MD dir1  && Create C:\temp\dir1
MD dir2  && Create C:\temp\dir2

* Create table yourfile.ext in dir1
CD c:\temp\dir1
lnFileHandle = FCREATE( "yourfile.ext")
=FCLOSE( lnFileHandle)

SET PATH to C:\temp\dir1  && dir1 has yourfile.ext in it
CD C:\temp\dir2  && dir2 has no files in it

* Use FILE() to check if yourfile.ext exists
?"Path = " + SET( "path") && Confirm path points to C:\temp\dir1
?"Curdir = " + SYS(5) + SYS(2003)  && Confirm current directory is C:\temp\dir2
?FILE( "yourfile.ext")  && True because yourfile.ext is in the path
?FILE( "c:\temp\dir2\yourfile.ext")  && False because yourfile.ext is not in dir2

CD &lcCurDir
You get the same result with the more generic SYS(2003)
?FILE( ADDBS( SYS(2003)) + "yourfile.ext")  && False because yourfile.ext is not in dir2
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform