Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File() function returns different value on the Network

Status
Not open for further replies.

dstema

Programmer
May 6, 2001
20
0
0
US
Hi everybody,
I'm using FoxPro 2.5 under Novell NetWare 5.0.
The following piece of code gives me a different result based on current directory.
On my computer (local) it gives me .F. while on the network it gives me .T.

lcwfile=''
....
if file(lcwfile+'.dbf')

More than that, if there is a
delete file (lcwfile+'.dbf')
it tries to delete all dbf files from current directory (network only).

Any idea why?
Thanks

 

There is an implied '*.dbf' when you do a DIR .DBF.
As a test, go to a DOS command prompt and do a DIR .dbf somewhere where you know there is .dbf(s). You will get a listing of all the .DBF's in the current directory. So if lcwfile = '', it is going to find any .dbf.

A safe way to do this instead would be something like

Code:
IF LEN(ALLTRIM(lcwfile)) > 0
   IF FILE(lcwfile+'.dbf')
      DELETE FILE (lcwfile + '.dbf')
   ENDIF
ENDIF

Dave S.
 
Thanks Dave,
It works.
I still not uderstand why if the current directory is on my local machine file() funcion and delete file command behave as the documntation says and if current directory is on the network they return another result.
Is this how it's supposed to be?
 
It shouldn't be that way. But you never know how good Microsoft and Novell are going to get along. In other words, the OS might interpret a command a certain way, and the network might interpret it differently via a driver placed on the local machine. The best thing to do is make sure there is no ambiguity. Be as specific as possible when doing "dangerous" functions like deleting files/records.

Dave S.

 
Dstema,
you have probably SET EXACT OFF.
Its danger, as empty string is equal any other string.
Function FILE() search specified file in
- current directory
- in path specified in SET PATH TO.
Good idea is before FILE()
SET DEFAULT TO and write full path...
 
I believe the difference in handling &quot;.DBF&quot; is based on a Novell configuration option (maybe even a Client configuration <s>). I NEVER use the FILE() function because of the possibility of it looking other than where you explicitly tell it to. Instead I use the following function - GOTFILE() - it works as long as you aren't processing in a SYS(2000) wildcard loop.

*FUNCTION gotfile
LPARAMETERS zcfilename
IF TYPE(&quot;zcfilename&quot;) <> &quot;C&quot;
RETURN .F.
ENDIF
* -- Check for existence of the filespec and return <exprL>
RETURN !EMPTY(SYS(2000, zcfilename))


Rick
 
Now it seems to me to be a Novell client problem. The abnormal behavior of file() and delete command disappears when using a combination of Fox 2.5+Novell 5+Win Me instead of Fox 2.5+Novell5+Win 98.
Win Me has its own Novell client and maybe this is the reason not to get a wrong return value while using it.
Nice function rgbean!
Thanks to everyone!

dstema
 
Getting the same result using the above gotfile() function.
In that specific environment every single call to OS interprets '.ext' as '*.ext'.
 
Yes, that's possible, I never suggested you shouldn't include Dave's &quot;no file&quot; checking code. I presented GOTFILE() to fix the other problem - where a file was &quot;found&quot; but it doesn't actually exist where you expected it.

Did you check the Novell configurations (both client and server) to see if the &quot;assumed '*'&quot; could be reset? Have you checked Novell's web site to see if they have a documented fix/workaround? (The FoxPro community has &quot;discovered&quot; more Novell problems than what might be considered it's share. FP exercises the network, both client and server, substantially more than a &quot;typical&quot; application.)

Rick
 
I got it!
I was using 3.1.0.0 novell client. I just updated my client software to the current 3.30 version and the foxpro FILE() and DELETE command work fine.
 
Congrats, just make sure you warn your clients that they may get &quot;undesirable&quot; results if they aren't using the same setup as you now have.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top