-------------------------------------------------------------------------------------------
                      [ENHANCED] VFP 9.0 FIX - ALWAYS ADD THE NOFILTER OPTION IN THE INTO CURSOR CLAUSE
                                September 2024
                 -------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), sometimes (only a single table, no calculated fields, and fully optimizable)
     the INTO CURSOR CursorName clause opens the original table again in another work area, and sets filter to lFilter,
     and sets filelds to cFields, it does not create a real cursor.

     In VFP Advanced, if we enable always adding the NOFILTER option in the INTO CURSOR clause,
     the INTO CURSOR CursorName clause is the same as the INTO CURSOR CursorName NOFILTER clause,
     it always creates a real cursor.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun536d15 :: ; proc near
             sub esp , 0350h                                                 ;0x00536d15 :        81ec50030000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x00536d1b :        a190709300
             mov  ecx , dword ptr [ Data9393ac ]                             ;0x00536d20 :        8b0dac939300
             push ebx                                                        ;0x00536d26 :        53
             push ebp                                                        ;0x00536d27 :        55
             mov  ebp , dword ptr [ esp + 035Ch ]                            ;0x00536d28 :        8bac245c030000
             push esi                                                        ;0x00536d2f :        56
             mov  dword ptr [ esp + 0358h ] , eax                            ;0x00536d30 :        89842458030000
             mov  al , byte ptr [ecx]                                        ;0x00536d37 :        8a01
             push edi                                                        ;0x00536d39 :        57
             xor edi , edi                                                   ;0x00536d3a :        33ff
             cmp al , 0FEh                                                   ;0x00536d3c :        3cfe
             mov  dword ptr [ esp + 20 ] , edi                               ;0x00536d3e :        897c2414
             je Label536dd3                                                  ;0x00536d42 :        0f848b000000

     Label536d48 ::
             movzx eax , al                                                  ;0x00536d48 :        0fb6c0
             add eax , 0FFFFFFE1h                                            ;0x00536d4b :        83c0e1
             cmp eax , 0DDh                                                  ;0x00536d4e :        3ddd000000
             ja Label4a6598                                                  ;0x00536d53 :        0f873ff8f6ff
             movzx eax ,byte ptr [ eax + offset Data5362d0 ]                          ;0x00536d59 :        0fb680d0625300
             jmp  dword ptr [ 4 * eax + offset DataPtr536df0 ]                           ;0x00536d60 :        ff2485f06d5300

     Label536d67 ::
             lea esi ,  dword ptr [ esp + 24 ]                               ;0x00536d67 :        8d742418
             call Fun42107e                                                  ;0x00536d6b :        e80ea3eeff
             mov  edx , dword ptr [ Data9393ac ]                             ;0x00536d70 :        8b15ac939300
             mov  al , byte ptr [edx]                                        ;0x00536d76 :        8a02
             cmp al , 031h                                                   ;0x00536d78 :        3c31
             je Label5e6d51                                                  ;0x00536d7a :        0f84d1ff0a00
             cmp al , 0BDh                                                   ;0x00536d80 :        3cbd
             jne Label4a6549                                                 ;0x00536d82 :        0f85c1f7f6ff
             lea esi ,  dword ptr [ esp + 24 ]                               ;0x00536d88 :        8d742418
             call Fun42107e                                                  ;0x00536d8c :        e8eda2eeff
             mov eax ,  dword ptr [ Data9393ac ]                             ;0x00536d91 :        a1ac939300
             mov  dword ptr [ ebp + 0164h ] , eax                            ;0x00536d96 :        898564010000
             mov  eax , dword ptr [ ebp + 8 ]                                ;0x00536d9c :        8b4508
             test eax , eax                                                  ;0x00536d9f :        85c0
             jne Label536dc3                                                 ;0x00536da1 :        7520
             pushd 00h                                                       ;0x00536da3 :        6a00
             xor ecx , ecx                                                   ;0x00536da5 :        33c9
             call Fun52ed72                                                  ;0x00536da7 :        e8c67fffff
             mov edx , eax                                                   ;0x00536dac :        8bd0
             mov  dword ptr [ ebp + 0174h ] , eax                            ;0x00536dae :        898574010000
             call Fun531d42                                                  ;0x00536db4 :        e889afffff
             mov esi , eax                                                   ;0x00536db9 :        8bf0
             test esi , esi                                                  ;0x00536dbb :        85f6
             jne Label5e6eee                                                 ;0x00536dbd :        0f852b010b00

     Label536dc3 ::
             mov  ecx , dword ptr [ Data9393ac ]                             ;0x00536dc3 :        8b0dac939300
             mov  al , byte ptr [ecx]                                        ;0x00536dc9 :        8a01
             cmp al , 0FEh                                                   ;0x00536dcb :        3cfe
             jne Label536d48                                                 ;0x00536dcd :        0f8575ffffff

     Label536dd3 ::


     ;
     ;                 --------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - ALWAYS ADD THE NOFILTER OPTION IN THE INTO CURSOR CLAUSE
     ;                                September 2024
     ;                 --------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Always add the NOFILTER option in the INTO CURSOR clause.
     ;
     ; 2024/9/8, by ccb
     ;

     Label536dd4_start ::
             cmp dword ptr vfpa_sys9167_data,00h
             je Label536dd4_end
             cmp dword ptr [ ebp + 0164h ] , 00h
             je Label536dd4_end
             or dword ptr [ ebp + 0B4h ] , 01h
     Label536dd4_end ::


     Label536dd6 ::
             mov  ecx , dword ptr [ esp + 035Ch ]                            ;0x00536dd3 :        8b8c245c030000
             call Fun42bf1d                                                  ;0x00536dda :        e83e51efff
             pop edi                                                         ;0x00536ddf :        5f
             pop esi                                                         ;0x00536de0 :        5e
             pop ebp                                                         ;0x00536de1 :        5d
             pop ebx                                                         ;0x00536de2 :        5b
             add esp , 0350h                                                 ;0x00536de3 :        81c450030000
             ret 04h                                                         ;0x00536de9 :        c20400


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
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix342.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix344.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix345.asp


6. OTHER:

     For reference only, there is no guarantees.

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