Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test for Open File
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01097778
Message ID:
01097790
Views:
14
You could always use try..catch.

Einar

>I set up the following code, but have not yet done the loop for it. My problem is that when I was testing this, the return value was -1, which means that I would not be able to open the file. However, within a split second I opened it manually, so I don't know if I can trust this FOPEN function to return a true value. My purpose is to keep my program from bombing if I cannot successfully open the file exclusively and then have the user wait until the file can be opened exclusively.
>
>[Tedious explanation: The same filename is used earlier in the program, but is actually a copy of the one on our network and we open it on drive c:\ locally. In regard to the file below it is the one on the network and I need to update it after closing the file by the same name on the local drive.]
>
>Here's my code, without the loop yet. (I'll do the loop later.)
>
>
>*** 02/21/2006 Cecil Champenois. We need to set this up so that the user
>*** waits here until the following Production file is able to be opened.
>LOCAL lcFileName, lcMessageText AS Character
>LOCAL lnSuccess AS Number
>#DEFINE NREADWRITE 12
>lcFileName="E:\PRODUCTION\DATA\PRODUCTION"
>lnSuccess=FOPEN(lcFileName, NREADWRITE)
>=FCLOSE(lcFileName)
>lcMessageText="Field is in use by another user."
>lcTitleText  ="Please wait for file to be available"
>IF lnSuccess < 0
>	MESSAGEBOX(lcMessageText, 0, lcTitleText)
>ELSE
>	* The file is not being used by anyone so, open it now.
>	USE (lcFileName) EXCLUSIVE ALIAS PROD_E
>ENDIF
>
Semper ubi sub ubi.
Previous
Reply
Map
View

Click here to load this message in the networking platform