------------------------------------------------------------------------------------------------
[BUG/PRB.] VFP 9.0 FIX - CHECK THE DESTINATION FILE FOR THE CREATE TABLE FILE COMMANDS
January 2026
------------------------------------------------------------------------------------------------
CCB
1. BUG:
In vfp9 (and vfp6, vfp7, vfp8), for the create table file commands,
if the file extension of the destination file is not .dbf,
it will NOT delete the destination cdx file, sometimes the destination cdx file is damaged.
There is a test program:
*PROC testcopytotablefilewithcdx
USE testtmpa.tmp
COPY TO testtmpc.tmp WITH CDX
USE
RETURN
* END OF PROC TESTCOPYTOTABLEFILEWITHCDX.
We think it will run fine, but sometimes the destination cdx file is damaged.
2. CAUSE:
In vfp9 (and vfp6, vfp7, vfp8), for the following COPY TO command:
COPY TO test.dbf WITH CDX
if the destination cdx file (test.cdx) exists, it will delete the destination cdx file first,
and then copy data to the destination table file,
and then create the destination cdx file.
In vfp9 (and vfp6, vfp7, vfp8), for the following COPY TO command:
COPY TO test.tmp WITH CDX
if the destination cdx file (test.cdx) exists, it will NOT delete the destination cdx file,
it will copy data to the destination table file,
and then copy/add the tags and index expressions to the destination cdx file,
sometimes the destination cdx file is damaged.
In Visual FoxPro Advanced, for the following COPY TO commands:
COPY TO test.dbf WITH CDX
COPY TO test.tmp WITH CDX
if the destination cdx file (test.cdx) exists, it will delete the destination cdx file first,
and then copy data to the destination table file,
and then create the destination cdx file.
3. RESOLUTION:
We can write some code to fix the BUG.
Fun4145d6 :: ; proc near
push ebp ;0x004145d6 : 55
mov ebp , esp ;0x004145d7 : 8bec
and esp , 0FFFFFFF8h ;0x004145d9 : 83e4f8
sub esp , 021Ch ;0x004145dc : 81ec1c020000
mov eax , dword ptr [ Data937090 ] ;0x004145e2 : a190709300
push ebx ;0x004145e7 : 53
push esi ;0x004145e8 : 56
mov dword ptr [ esp + 0220h ] , eax ;0x004145e9 : 89842420020000
push edi ;0x004145f0 : 57
lea eax , dword ptr [ esp + 0118h ] ;0x004145f1 : 8d842418010000
mov ebx , ecx ;0x004145f8 : 8bd9
call Fun41975b ;0x004145fa : e85c510000
mov eax , dword ptr [ ebp + 16 ] ;0x004145ff : 8b4510
test eax , eax ;0x00414602 : 85c0
je Label41464c ;0x00414604 : 7446
;
; -------------------------------------------------------------------------------------
; VFP 9.0 FIX - CHECK THE DESTINATION FILE FOR THE CREATE TABLE FILE COMMANDS
; June 2022
; -------------------------------------------------------------------------------------
; CCB
;
; Check the destination file for the create table file commands.
;
; 2022/6/17, by ccb
;
cmp dword ptr vfpa_sys9102_data,00h
je Label4148d0
lea eax , dword ptr [ esp + 0118h ] ;0x00414606 : 8d842418010000
pushd 05Ch ;0x0041460d : 6a5c
push eax ;0x0041460f : 50
call dword ptr [ Data9370d0 ] ;0x00414610 : ff15d0709300
add esp , 08h ;0x00414616 : 83c408
test eax , eax ;0x00414619 : 85c0
je Label57e7cd ;0x0041461b : 0f84aca11600
Label414621 ::
pushd 02Eh ;0x00414621 : 6a2e
push eax ;0x00414623 : 50
call dword ptr [ Data9370d0 ] ;0x00414624 : ff15d0709300
add esp , 08h ;0x0041462a : 83c408
test eax , eax ;0x0041462d : 85c0
je Label41464c ;0x0041462f : 741b
inc eax ;0x00414631 : 40
pushd offset Data919ea0 ;0x00414632 : 68a09e9100
push eax ;0x00414637 : 50
call dword ptr [ Data9370d8 ] ;0x00414638 : ff15d8709300
add esp , 08h ;0x0041463e : 83c408
neg eax ;0x00414641 : f7d8
sbb eax , eax ;0x00414643 : 1bc0
inc eax ;0x00414645 : 40
jne Label4148d0 ;0x00414646 : 0f8584020000
Label41464c ::
mov esi , dword ptr [ ebp + 8 ] ;0x0041464c : 8b7508
mov edx , dword ptr [ esi + 32 ] ;0x0041464f : 8b5620
xor ecx , ecx ;0x00414652 : 33c9
mov cl , byte ptr [ Data933758 ] ;0x00414654 : 8a0d58379300
and edx , 0FF7FFEC7h ;0x0041465a : 81e2c7fe7fff
xor eax , eax ;0x00414660 : 33c0
mov dword ptr [ esi + 8 ] , 0FFFFFFFFh ;0x00414662 : c74608ffffffff
mov dword ptr [ esi + 36 ] , eax ;0x00414669 : 894624
mov dword ptr [esi] , ebx ;0x0041466c : 891e
mov dword ptr [ esi + 40 ] , 01h ;0x0041466e : c7462801000000
and ecx , 01h ;0x00414675 : 83e101
shl ecx , 03h ;0x00414678 : c1e103
or ecx , edx ;0x0041467b : 0bca
or ecx , 03h ;0x0041467d : 83c903
mov dword ptr [ esi + 60 ] , eax ;0x00414680 : 89463c
mov dword ptr [ esi + 104 ] , eax ;0x00414683 : 894668
mov dword ptr [ esi + 32 ] , ecx ;0x00414686 : 894e20
call GetTickCount ;0x00414689 : ff15f8709100
mov edi , eax ;0x0041468f : 8bf8
cmp edi , dword ptr [ Data937ec8 ] ;0x00414691 : 3b3dc87e9300
jb Label57e7e7 ;0x00414697 : 0f824aa11600
Label41469d ::
push edi ;0x0041469d : 57
pushd offset Data937ec8 ;0x0041469e : 68c87e9300
call InterlockedExchange ;0x004146a3 : ff1594719100
mov eax , dword ptr [ Data937ec0 ] ;0x004146a9 : a1c07e9300
add eax , edi ;0x004146ae : 03c7
mov edi , dword ptr [ ebp + 24 ] ;0x004146b0 : 8b7d18
mov dword ptr [ esi + 0A8h ] , eax ;0x004146b3 : 8986a8000000
mov eax , edi ;0x004146b9 : 8bc7
mov dword ptr [ esi + 0ACh ] , 00h ;0x004146bb : c786ac00000000000000
call Fun41e447 ;0x004146c5 : e87d9d0000
push esi ;0x004146ca : 56
call Fun414160 ;0x004146cb : e890faffff
test eax , eax ;0x004146d0 : 85c0
jne Label413e14 ;0x004146d2 : 0f853cf7ffff
Label4146d8 ::
mov dword ptr [ esi + 4 ] , 0FFFFFFFFh ;0x004146d8 : c74604ffffffff
Label4146df ::
pushd 0181Ah ;0x004146df : 681a180000
mov eax , 024h ;0x004146e4 : b824000000
call Fun42bf2a ;0x004146e9 : e83c780100
mov dword ptr [ esi + 108 ] , eax ;0x004146ee : 89466c
call Fun41979f ;0x004146f1 : e8a9500000
mov eax , dword ptr [ esi + 32 ] ;0x004146f6 : 8b4620
test byte ptr ah , 084h ;0x004146f9 : f6c484
jne Label517613 ;0x004146fc : 0f85112f1000
test al , al ;0x00414702 : 84c0
js Label517613 ;0x00414704 : 0f88092f1000
mov eax , dword ptr [ esi + 92 ] ;0x0041470a : 8b465c
test eax , eax ;0x0041470d : 85c0
jne Label517613 ;0x0041470f : 0f85fe2e1000
Label414715 ::
mov edx , dword ptr [ esi + 40 ] ;0x00414715 : 8b5628
mov ecx , dword ptr [ esp + 0224h ] ;0x00414718 : 8b8c2424020000
mov dword ptr [ esi + 44 ] , edx ;0x0041471f : 89562c
mov eax , dword ptr [ Data93889c ] ;0x00414722 : a19c889300
mov dword ptr [ esi + 0B8h ] , eax ;0x00414727 : 8986b8000000
mov dword ptr [ Data93889c ] , esi ;0x0041472d : 89359c889300
call Fun42bf1d ;0x00414733 : e8e5770100
pop edi ;0x00414738 : 5f
pop esi ;0x00414739 : 5e
pop ebx ;0x0041473a : 5b
mov esp , ebp ;0x0041473b : 8be5
pop ebp ;0x0041473d : 5d
ret 014h ;0x0041473e : c21400
4. APPLIES TO:
VFP 6.0.8167.0
VFP 6.0.8961.0 (SP5)
VFP 7.0.0.9262
VFP 7.0.0.9465 (SP1)
VFP 8.0.0.2521
VFP 8.0.0.3117 (SP1)
VFP 9.0.0.2412
VFP 9.0.0.3504 (SP1)
VFP 9.0.0.4611 (SP2)
VFP 9.0.0.5015 (SP2)
VFP 9.0.0.5411 (SP2)
VFP 9.0.0.5721 (SP2)
VFP 9.0.0.5815 (SP2)
VFP 9.0.0.6303 (SP2)
VFP 9.0.0.6602 (SP2)
VFP 9.0.0.7423 (SP2)
The bug has been fixed in VFP Advanced.
IMPORTANT NOTE:
In vfp9 (and vfp6, vfp7, vfp8), we can delete the destination cdx file before run the COPY TO command, for example,
IF FILE("test.tmp")
DELETE FILE ("test.tmp")
ENDIF
IF FILE("test.cdx")
DELETE FILE ("test.cdx")
ENDIF
COPY TO ("test.tmp") WITH CDX
and then there is no the bug.
5. REFERENCE WEBSITES:
1, baiyujia.com:
http://www.baiyujia.com
http://www.baiyujia.com/vfpdocuments/f_vfp9fix216.asp
6. OTHER:
For reference only, there is no guarantees.
Any questions or suggestions, please send me an email at ccb2000@163.com.
|