------------------------------------------------------------
                     [ENHANCED] VFP 9.0 FIX - REPLACE COMMAND FIELDS COUNT
                                 January 2024
                 ------------------------------------------------------------
                                    CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), the REPLACE command can only use <= 127 fields, now it can use <= 255 fields.

     There is no the bug for the UPDATE command, it can use <= 254 fields.

     The bug was reported by Mike Yearwood.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label52e420 ::
             lea edx ,  dword ptr [ ebp - 28 ]                               ;0x0052e420 :        8d55e4
             lea eax ,  dword ptr [ ebp + 0FFFFFF38h ]                       ;0x0052e423 :        8d8538ffffff
             call Fun42c27f                                                  ;0x0052e429 :        e851deefff
             push edi                                                        ;0x0052e42e :        57
             push eax                                                        ;0x0052e42f :        50
             call Fun42c2be                                                  ;0x0052e430 :        e889deefff
             add esp , 08h                                                   ;0x0052e435 :        83c408
             cmp eax , edi                                                   ;0x0052e438 :        3bc7
             mov  dword ptr [ ebp - 32 ] , eax                               ;0x0052e43a :        8945e0
             jne Label52e3aa                                                 ;0x0052e43d :        0f8567ffffff
             mov eax ,  dword ptr [ Data9370f8 ]                             ;0x0052e443 :        a1f8709300
             mov  ecx , dword ptr [eax]                                      ;0x0052e448 :        8b08
             mov  edx , dword ptr [ ecx + 0A8h ]                             ;0x0052e44a :        8b91a8000000
             push edx                                                        ;0x0052e450 :        52
             xor edx , edx                                                   ;0x0052e451 :        33d2
             xor ecx , ecx                                                   ;0x0052e453 :        33c9
             call Fun52d14e                                                  ;0x0052e455 :        e8f4ecffff
             mov eax ,  dword ptr [ Data9393ac ]                             ;0x0052e45a :        a1ac939300
             cmp  byte ptr [eax] , 015h                                      ;0x0052e45f :        803815
             je Label5d8b1c                                                  ;0x0052e462 :        0f84b4a60a00
             xor eax , eax                                                   ;0x0052e468 :        33c0
             call Fun42c118                                                  ;0x0052e46a :        e8a9dcefff
             mov  edx , dword ptr [ Data9370c4 ]                             ;0x0052e46f :        8b15c4709300
             mov eax , esp                                                   ;0x0052e475 :        8bc4
             sub eax , edx                                                   ;0x0052e477 :        2bc2
             cmp eax , 2 * 0600h                                                 ;0x0052e479 :        3d00060000
             jle Label5d8b26                                                 ;0x0052e47e :        0f8ea2a60a00
             mov eax , 2 * 0600h                                                 ;0x0052e484 :        b800060000
             call Fun42c118                                                  ;0x0052e489 :        e88adcefff
             mov  dword ptr [ ebp - 16 ] , esp                               ;0x0052e48e :        8965f0

     Label52e491 ::
             mov  ebx , dword ptr [ ebp - 8 ]                                ;0x0052e491 :        8b5df8

     Label52e494 ::


     ;
     ;                 -------------------------------------------------
     ;                     VFP 9.0 FIX - REPLACE COMMAND FIELDS COUNT
     ;                                   August 2014
     ;                 -------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, the REPLACE command can only use <= 127 fields, now it can use <= 255 fields.
     ;
     ; 2014/8/22, by ccb
     ;


             cmp ebx , 2 * 080h                                                  ;0x0052e494 :        81fb80000000
             jnl Label5d8b2e                                                 ;0x0052e49a :        0f8d8ea60a00
             pushd 0FFFFFFFFh                                                ;0x0052e4a0 :        6aff
             mov edx , 01100h                                                ;0x0052e4a2 :        ba00110000
             lea ecx ,  dword ptr [ ebp - 80 ]                               ;0x0052e4a7 :        8d4db0
             call Fun421184                                                  ;0x0052e4aa :        e8d52cefff
             mov  edx , dword ptr [ ebp - 16 ]                               ;0x0052e4af :        8b55f0
             mov  ax , word ptr [ ebp - 72 ]                                 ;0x0052e4b2 :        668b45b8
             lea ecx ,  dword ptr [ ebx + 2 * ebx ]                          ;0x0052e4b6 :        8d0c5b
             lea edi ,  dword ptr [ edx + 4 * ecx ]                          ;0x0052e4b9 :        8d3c8a
             mov  ecx , dword ptr [ Data9370f8 ]                             ;0x0052e4bc :        8b0df8709300
             mov  word ptr [edi] , ax                                        ;0x0052e4c2 :        668907
             mov  edx , dword ptr [ecx]                                      ;0x0052e4c5 :        8b11
             mov  eax , dword ptr [ edx + 8 ]                                ;0x0052e4c7 :        8b4208
             test eax , eax                                                  ;0x0052e4ca :        85c0
             je Label5d8b38                                                  ;0x0052e4cc :        0f8466a60a00
             mov  edx , dword ptr [ ebp - 76 ]                               ;0x0052e4d2 :        8b55b4


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.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com

     2, codeplex.com:
     http://vfpx.codeplex.com/workitem/35381

     3, foxite.com:
     http://www.foxite.com/archives/undocummented-limitation-found-0000003165.htm


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.