Home > Archive > Clipper > July 2005 > FILE() and "CA-Clipper path"
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
FILE() and "CA-Clipper path"
|
|
| Kurt Remlin 2005-07-24, 8:17 pm |
| Description for FILE() says:
========================================
============================
FILE() searches the specified directory if a path is explicitly
specified.
If a path is not specified, FILE() searches the current CA-Clipper
default directory and then the CA-Clipper path.
========================================
============================
Please pardon my ignorance but what is "Clipper path"? How's it
determined?
| |
| Klas Engwall 2005-07-24, 8:17 pm |
| Kurt,
>Description for FILE() says:
>
> ========================================
============================
>FILE() searches the specified directory if a path is explicitly
>specified.
>
>If a path is not specified, FILE() searches the current CA-Clipper
> default directory and then the CA-Clipper path.
> ========================================
============================
>
>Please pardon my ignorance but what is "Clipper path"? How's it
>determined?
You stopped reading a little too soon <g>:
? FILE("Sales.dbf") // Result: .F.
? FILE("\APPS\DBF\Sales.dbf") // Result: .T.
//
SET PATH TO \APPS\DBF
? FILE("Sales.dbf") // Result: .T.
//
SET PATH TO
SET DEFAULT TO \APPS\DBF\
? FILE("Sales.dbf") // Result: .T.
? FILE("*.dbf") // Result: .T.
Regards,
Klas
-------
klas dot engwall at engwall dot com
http://www.engwall.com/clipper/
The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
| |
| Kurt Remlin 2005-07-24, 8:17 pm |
| Klas,
So if I scan the source code for "SET PATH" and "SET DEFAULT" strings
and do not find any, can I be absolutely certain that FILE function
will just search the current directory and nothing else?
| |
| Ross McKenzie 2005-07-24, 8:17 pm |
| On 21 Jul 2005 15:29:53 -0700, "Kurt Remlin" <pm771@netscape.net>
wrote:
>Klas,
>
>So if I scan the source code for "SET PATH" and "SET DEFAULT" strings
>and do not find any, can I be absolutely certain that FILE function
>will just search the current directory and nothing else?
>
Hello Kurt.
In a word...no. Some people, including myself, have been known to
reuse code that for convenience had a "path" defined as per below...
static cDataDir := "C:\MYAPP\DATA\"
and then somewhere else
if File ( cDataDir + "ACCOUNTS.DBF" )
Regards,
Ross McKenzie
ValuSoft
Melbourne Australia
valusoft AT optusnet DOT com DOT au
Pain and disappointment are inevitable. Misery is optional.
| |
| Nick Ramsay 2005-07-24, 8:17 pm |
| On 21 Jul 2005 15:29:53 -0700, "Kurt Remlin" <pm771@netscape.net>
wrote:
>Klas,
>
>So if I scan the source code for "SET PATH" and "SET DEFAULT" strings
>and do not find any, can I be absolutely certain that FILE function
>will just search the current directory and nothing else?
The surest way would be to define the current directory like this:
if file(".\file2check")
That way, there's absolutely no doubt about where you are looking.
| |
| Klas Engwall 2005-07-24, 8:17 pm |
| Kurt,
>So if I scan the source code for "SET PATH" and "SET DEFAULT" strings
>and do not find any, can I be absolutely certain that FILE function
>will just search the current directory and nothing else?
You can never be absolutely certain of anything in this world <g>.
Having used several other xBase products before I found Clipper I
quickly learned to never trust the defaults. So I always supply a
fully qualified path to all file related functions. And I always
supply the size arguments to str(), etc. Belt and suspenders ...
Regards,
Klas
-------
klas dot engwall at engwall dot com
http://www.engwall.com/clipper/
The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
| |
| Kurt Remlin 2005-07-24, 8:17 pm |
| Ross,
I guess I have not put my question the right way. Let me try again.
If I do not find any "SET PATH" and "SET DEFAULT" statements anywhere
in a source code, does it mean that FILE() functions will always scan a
single directory (current or not)? In other words, is there a case
when FILE() will look into multiple directories if there are no "PATH"
or "DEFAULT" settings in the code?
Thank you.
| |
| Klas Engwall 2005-07-24, 8:17 pm |
| Kurt,
>I guess I have not put my question the right way. Let me try again.
I think we all understand both versions of your question. What we do
not quite understand is _why_ you are asking those questions. Are you
trying to solve a specific problem where FILE() returns an unexpected
positive result? If so, what are the circumstances?
>If I do not find any "SET PATH" and "SET DEFAULT" statements anywhere
>in a source code, does it mean that FILE() functions will always scan a
>single directory (current or not)? In other words, is there a case
>when FILE() will look into multiple directories if there are no "PATH"
>or "DEFAULT" settings in the code?
In the absence of test results indicating that it will or will not do
that under various unusual circumstances, you will probably have to
rely on what the manual says:
"FILE() searches the specified directory if a path is explicitly
specified. If a path is not specified, FILE() searches the current
CA-Clipper default directory and then the CA-Clipper path. In no case
is the DOS path searched."
But to be absolutely sure that FILE() does exactly what you want it to
do, the best way is to tell it exactly what you want it to do, that
is, give it the path to the directory you want to search.
Regards,
Klas
-------
klas dot engwall at engwall dot com
http://www.engwall.com/clipper/
The LFN Library for Clipper
The LanMan Library for Clipper
The NFPAT1A Timeslice release patch for the Nanforum Toolkit
| |
| Ross McKenzie 2005-07-24, 8:17 pm |
| On 24 Jul 2005 13:23:54 -0700, "Kurt Remlin" <pm771@netscape.net>
wrote:
>Ross,
>
>I guess I have not put my question the right way. Let me try again.
>
>If I do not find any "SET PATH" and "SET DEFAULT" statements anywhere
>in a source code, does it mean that FILE() functions will always scan a
>single directory (current or not)? In other words, is there a case
>when FILE() will look into multiple directories if there are no "PATH"
>or "DEFAULT" settings in the code?
>
>Thank you.
>
Hi Kurt,
If the directory is not defined specifically by one of the set path,
set default or a directory string , the File() will only look in the
current directory. The directory string may be obfuscated. Such
obfuscation may include the following techniques.
cFileName := cDataDir + "MyFile.DBF"
cFileName := curdrive() + curdir() + "MyFile.DBF"
cFileName := SYSTEM->FileDef + "MyFile.DBF"
if File( cFileName )
.....
But rather than obfuscate this question <g>...how about telling us
what your problem is?
Regards,
Ross McKenzie
ValuSoft
Melbourne Australia
valusoft AT optusnet DOT com DOT au
| |
| Kurt Remlin 2005-07-26, 4:59 pm |
| Also instead of "SET TO" statements there could be SET() function calls
either with "_SET_DEFAULT" / "_SET_PATH" character constants or their
integer counterparts from SET.CH.
|
|
|
|
|