Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check to see if a file is open
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:
01223969
Message ID:
01223980
Views:
35
For a table forget about FOPEN, use try/catch as I suggested. Now, what if the file you're trying to append from is also opened by someone? Though AFAIK it should not give your a problem.

Just wrap the whole code in try/catch.

If you want to be able to retry, then it's a different story, need to think a bit more, but currently working on something else.

>Well, I am trying to append to a table from a spreadsheet. I may let the user sit in a loop and let the user re-attempt to use the file either a limited number of tries, or make the user wait forever until the file is available again, or? I'll have to think about this. What I need to do is to track down where that file is used and see that it is only used in SHARE mode.
>
>
>SET PATH TO E:\IRL\SHIP
>lnFileHandle=FOPEN("E:\IRL\SHIP\ORDERS.DBF", 12)
>IF lnFileHandle <> -1	&& File is open.
>   =FCLOSE(lnFileHandle)	&& Close at low-level immediately.
>   WAIT WINDOW NOWAIT "Zapping records from ORDERS table..."
>   USE E:\IRL\SHIP\ORDERS EXCLUSIVE IN 0
>   SELECT ORDERS	&& 10/29/2004. Cecil Champenois.
>   ZAP
>ELSE
>   lcMessageText=""
>   lcTitleBar=""
>   MESSAGEBOX(lcMessageText, 0+64, lcTitleBar)
>ENDIF
>WAIT WINDOW NOWAIT ;
>   "Appending records from the I:\DIV_04\Daily\OE531S_4.XLS" + ;
>   + chr(10) + chr(13) + ;
>   "spreadsheet into the E:\IRL\SHIP\ORDERS table..."
>IF FILE("I:\DIV_04\Daily\OE531S_04.XLS")
>   APPEND FROM I:\Div_04\Daily\OE531S_04.XLS TYPE XLS
>   USE
>ELSE
>   *** You've got to close this here. It is used further down the chain.
>   SELECT ORDERS
>   USE
>   lcMessageText="File: I:\DIV_04\Daily\OE531S_04.XLS not found."
>   lcTitleBar="File not found!"
>   MESSAGEBOX(lcMessageText, 0+64, lcTitleBar)
>ENDIF
>
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform