Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Incredible bug ?
Message
From
03/01/2009 05:37:18
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Miscellaneous
Thread ID:
01370762
Message ID:
01370813
Views:
21
>Hi.
>
> select 0
> use c:\somedir\somtable.dbf shared
>
> Now I go to another directory copy table at the same name return to main directory make "paste" nad what ? System
>replace IT !!!
>
> best regards

But this it is a bug for me.
FLOCK() don't lock the file; it should.
* W2KBugTest.PRG

#DEFINE hcCurrDir		SYS(5) + CURDIR()

MD _Test1
MD _Test2

CREATE TABLE _Test1\Test ;
	(cTest C(20))

INSERT INTO Test ;
	(cTest) ;
	VALUES ;
		("VFP table lock")

USE IN Test

CREATE TABLE _Test2\Test ;
	(cTest C(10))

INSERT INTO Test ;
	(cTest) ;
	VALUES ;
		("Test 2")

CLOSE DATABASES ALL

SET EXCLUSIVE OFF

USE _Test1\Test SHARED

DO WHILE NOT FLOCK()
	MESSAGEBOX(MESSAGE())
ENDDO
MESSAGEBOX("table is locked :"+TRANSFORM(ISFLOCKED())+0hD0A + "replace it with explorer")
* Try to copy _Test2\Test.dbf over top of _Test1\Test.dbf while the latter is open:

* Following line should fail, because target file is in use:
* Following line DOES fail with EXCLUSIVE OFF or ON, so is commented out here:
*!*	COPY FILE _Test2\Test.DBF TO _Test1\Test.DBF

* Try the File System Object (presumably the same as what underlies Windows Explorer):
loFSO = CREATEOBJECT("Scripting.FileSystemObject")
loFSO.CopyFile(hcCurrDir + "_Test2\Test.dbf",DBF("Test"))
RELEASE loFSO
* Note that the preceding CopyFile call fails if SET EXCLUSIVE is ON

=MESSAGEBOX("Test table "+DBF("Test")+" has been overwritten while open," + CHR(13) + ;
	"but its cTest value is still: " + Test.cTest, ;
	0 + 64 + 0, ;
	"Step 1")

USE IN Test
USE _Test1\Test

=MESSAGEBOX("Test table "+DBF("Test")+" has been closed, and re-opened." + CHR(13) + ;
	"Its cTest value is now: " + Test.cTest, ;
	0 + 64 + 0, ;
	"Step 2")

CLOSE TABLES ALL

ERASE _Test1\Test.DBF
ERASE _Test2\Test.DBF
RD _Test1
RD _Test2
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform