Well, I never. 10.2B03
DEF VAR lv_file AS CHAR NO-UNDO INIT "c:\temp".
ASSIGN FILE-INFO:FILE-NAME = SEARCH(lv_File).
MESSAGE "1" lv_File SKIP
"2" SEARCH(lv_File) SKIP
"3" FILE-INFO:FILE-NAME SKIP
"4" FILE-INFO:FULL-PATHNAME
VIEW-AS ALERT-BOX.
What's wrong with this ? Well, it doesn't work.
Now, I'm sure that at one stage (v3 - v10) it used to ...
from the documentation:
1) Use the SEARCH function to ensure that procedures that get input from external data files are independent of specific directory paths. The files must be in one of the directories or libraries defined in the PROPATH environment variable
which makes sense of why this isn't working
BUT .. THEN ..
2) If you provide a fully qualified pathname, SEARCH checks if the file exists. In this case, SEARCH does not search directories on the PROPATH.
AFAIK, "c:\temp" is a fully qualified pathname
Now, change "c:\temp" to "c:\temp\somefile.txt"
AND IT NOW WORKS. AAARRRGGH
IOW, different behaviour for directories and files. not good.
AFAIR, SEARCH has never worked on directories. Pre-FILE-INFO, there were various kludges like putting a file in the target in order to have something to SEARCH for.
I can't remember that SEARCH ever returned directories.
FILE-INFO does look for files and directories. But when SEARCH already returns ? (because your are trying to lookup a dir, not a file), FILE-INFO will fail as well.
My point is that c:\temp is a fully-qualified pathname
Allow me to quote from the first two lines of the manual:
Searches the directories and libraries defined in the PROPATH environment variable for a file. The
SEARCH function returns the full pathname of the file unless it is found in your current working
directory.
Note the word "file".
meh.
A directory is a file. A special file, granted, but a file nonetheless.
On 29 March 2011 19:35, Thomas Mercer-Hursh
A directory is a file. A special file, granted, but a file nonetheless.
Not many people on windows would probably share that view.
Heck, even Unixieans wouldn't necessarily expect file to include directories in most cases.
.net disagrees with you
// get the file attributes for file or directory
FileAttributes attr = File.GetAttributes(@"c:\Temp");
//detect whether its a directory or file
if((attr & FileAttributes.Directory) == FileAttributes.Directory)
MessageBox.Show("Its a directory");
else
MessageBox.Show("Its a file");
.net disagrees with you
Using it each day, I got used to that
rotflmao