---------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - FIX THE POINTER OF P-CODE FOR THE ROWSOURCE PROPERTY
                                 February 2021
                 ---------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In VFP 9.0 and earlier versions, for the ComboBox control and the ListBox control,
     if we set the RowSourceType property to 2 (Table alias) or 6 (Fields),
     sometimes it occurs an error: Expression evaluator failed (Error 67).

     The bug occurs in vfp7, vfp8 and vfp9, it does not occur in vfp6.

     The bug only occurs when !ORDER()=="" (SET ORDER TO TagName), it does not occur when ORDER()=="" (SET ORDER TO).
     

2. CAUSE:

     In VFP 9.0 and earlier versions, for example,
     if we set ComboBox.RowSourceType = 6 (Fields) and ComboBox.RowSource = "table1.fld1",
     the RowSource property "table1.fld1" will be compiled to the p-code (total 9 bytes):
     FC F4 68 03 F7 6D 03 FD FE ?? ?? ?? ?? ?? ?? ??
     sometimes the pointer of p-code points to the end of the p-code (the 10th byte: ??),
     if the 10th byte is 0x1E (NEXT nRecords) or 0x23 (RECORD nRecordNumber),
     it occurs an error: Expression evaluator failed (Error 67).

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun45732d :: ; proc near
             push ebp                                                        ;0x0045732d :        55
             mov ebp , esp                                                   ;0x0045732e :        8bec
             sub esp , 068h                                                  ;0x00457330 :        83ec68
             push ebx                                                        ;0x00457333 :        53
             push esi                                                        ;0x00457334 :        56
             push edi                                                        ;0x00457335 :        57
             pushd 0180Ch                                                    ;0x00457336 :        680c180000
             mov eax , 0260h                                                 ;0x0045733b :        b860020000
             call Fun42bf2a                                                  ;0x00457340 :        e8e54bfdff
             mov  ecx , dword ptr [eax]                                      ;0x00457345 :        8b08
             mov  edx , dword ptr [ ebp + 8 ]                                ;0x00457347 :        8b5508
             mov  dword ptr [ ecx + 4 ] , 04h                                ;0x0045734a :        c7410404000000
             mov  ecx , dword ptr [eax]                                      ;0x00457351 :        8b08
             xor ebx , ebx                                                   ;0x00457353 :        33db
             mov  dword ptr [ ecx + 0258h ] , ebx                            ;0x00457355 :        899958020000
             mov  ecx , dword ptr [ Data9370f8 ]                             ;0x0045735b :        8b0df8709300
             mov  dword ptr [ ebp - 8 ] , eax                                ;0x00457361 :        8945f8
             mov  eax , dword ptr [eax]                                      ;0x00457364 :        8b00
             mov  dword ptr [ eax + 20 ] , ecx                               ;0x00457366 :        894814
             mov  ecx , dword ptr [ edx + 0140h ]                            ;0x00457369 :        8b8a40010000
             mov edx , 01h                                                   ;0x0045736f :        ba01000000
             call Fun42f404                                                  ;0x00457374 :        e88b80fdff
             mov  eax , dword ptr [eax]                                      ;0x00457379 :        8b00
             or  byte ptr [ eax + 4 ] , 01h                                  ;0x0045737b :        80480401
             mov eax ,  dword ptr [ Data9393ac ]                             ;0x0045737f :        a1ac939300
             mov  dword ptr [ ebp - 16 ] , eax                               ;0x00457384 :        8945f0
             lea edx ,  dword ptr [ ebp - 12 ]                               ;0x00457387 :        8d55f4
             lea eax ,  dword ptr [ ebp - 100 ]                              ;0x0045738a :        8d459c
             call Fun42c27f                                                  ;0x0045738d :        e8ed4efdff
             push ebx                                                        ;0x00457392 :        53
             push eax                                                        ;0x00457393 :        50
             call Fun42c2be                                                  ;0x00457394 :        e8254ffdff
             mov edi , eax                                                   ;0x00457399 :        8bf8
             add esp , 08h                                                   ;0x0045739b :        83c408
             cmp edi , ebx                                                   ;0x0045739e :        3bfb
             jne Label4573f1                                                 ;0x004573a0 :        754f
             cmp  dword ptr [ ebp + 16 ] , ebx                               ;0x004573a2 :        395d10
             mov  esi , dword ptr [ ebp - 8 ]                                ;0x004573a5 :        8b75f8
             jbe Label5eab6e                                                 ;0x004573a8 :        0f86c0371900
             mov  ecx , dword ptr [esi]                                      ;0x004573ae :        8b0e
             mov  eax , dword ptr [ ebp + 12 ]                               ;0x004573b0 :        8b450c
             mov  dword ptr [ ecx + 24 ] , ebx                               ;0x004573b3 :        895918
             mov  edx , dword ptr [esi]                                      ;0x004573b6 :        8b16
             push esi                                                        ;0x004573b8 :        56
             mov  dword ptr [ edx + 32 ] , ebx                               ;0x004573b9 :        895a20
             mov dword ptr [ Data9393ac ] ,  eax                             ;0x004573bc :        a3ac939300
             call Fun457433                                                  ;0x004573c1 :        e86d000000


     ;
     ;                 ----------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - FIX THE POINTER OF P-CODE FOR THE ROWSOURCE PROPERTY
     ;                                February 2021
     ;                 ----------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; Fix the pointer of p-code for the RowSource property.
     ;
     ; 2021/2/21, by ccb
     ;

             cmp dword ptr vfpa_sys9053_data,00h
             je Label4573c6
             cmp dword ptr [ esp + 078h ] , offset Label4cca83 ;; Fun4c70fc :: ; proc near
             je Label4573c5
             cmp dword ptr [ esp + 078h ] , offset Label5eaede ;; Fun4c70fc :: ; proc near
             je Label4573c5
             jmp Label4573c6
     Label4573c5 ::
             mov  edx , dword ptr [ ebp - 16 ]
             mov  dword ptr [ Data9393ac ] , edx


     Label4573c6 ::
             mov  ebx , dword ptr [ ebp + 8 ]                                ;0x004573c6 :        8b5d08
             mov  ecx , dword ptr [ ebx + 0140h ]                            ;0x004573c9 :        8b8b40010000
             mov edx , 01h                                                   ;0x004573cf :        ba01000000
             call Fun42f404                                                  ;0x004573d4 :        e82b80fdff
             mov  ecx , dword ptr [eax]                                      ;0x004573d9 :        8b08
             mov  dword ptr [ ecx + 0D0h ] , esi                             ;0x004573db :        89b1d0000000
             mov  edx , dword ptr [ ebx + 0140h ]                            ;0x004573e1 :        8b9340010000
             pushd 00h                                                       ;0x004573e7 :        6a00
             push edx                                                        ;0x004573e9 :        52
             call Fun456e21                                                  ;0x004573ea :        e832faffff
             xor ebx , ebx                                                   ;0x004573ef :        33db

     Label4573f1 ::
             mov  ecx , dword ptr [ Data937220 ]                             ;0x004573f1 :        8b0d20729300
             lea eax ,  dword ptr [ ebp - 100 ]                              ;0x004573f7 :        8d459c
             cmp eax , ecx                                                   ;0x004573fa :        3bc1
             jne Label5eab8e                                                 ;0x004573fc :        0f858c371900
             mov  ecx , dword ptr [ Data937220 ]                             ;0x00457402 :        8b0d20729300
             mov  eax , dword ptr [ ecx + 76 ]                               ;0x00457408 :        8b414c
             cmp  dword ptr [ ebp - 12 ] , eax                               ;0x0045740b :        3945f4
             mov dword ptr [ Data937220 ] ,  eax                             ;0x0045740e :        a320729300
             jne Label5eab98                                                 ;0x00457413 :        0f857f371900
             cmp edi , ebx                                                   ;0x00457419 :        3bfb
             mov  edx , dword ptr [ ebp - 16 ]                               ;0x0045741b :        8b55f0
             mov  dword ptr [ Data9393ac ] , edx                             ;0x0045741e :        8915ac939300
             jne Label5eaba2                                                 ;0x00457424 :        0f8578371900
             pop edi                                                         ;0x0045742a :        5f
             pop esi                                                         ;0x0045742b :        5e
             pop ebx                                                         ;0x0045742c :        5b
             mov esp , ebp                                                   ;0x0045742d :        8be5
             pop ebp                                                         ;0x0045742f :        5d
             ret 0Ch                                                         ;0x00457430 :        c20c00


4. APPLIES TO:

     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_vfp9fix157.asp

     2, foxite.com:
     https://www.foxite.com/archives/combolist-box-causes-error-67-0000061756.htm
     https://www.foxite.com/archives/error-67-expression-evaluator-failed-0000097598.htm

     3, microsoft.com:
     https://social.technet.microsoft.com/Forums/en-US/e6d46eca-dac8-4528-a697-69a69bf212e8/error-expression-evaluator-failed


6. OTHER:

     For reference only, there is no guarantees.

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