---------------------------------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - THE CURLY BRACKETS SUBSTITUTION IN THE SEND OUTPUT DIRECTLY TO THE PRINTER COMMAND
                                January 2024
                 ---------------------------------------------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), it always enables the curly brackets substitution in the send output directly to the printer command.

     In VFP Advanced, we can disable the curly brackets substitution in the send output directly to the printer command,
     for example,
     =SYS(9076,0)
     ???"a{b"
     the curly bracket "{" will not be replaced,
     it will run fine.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun8767ac :: ; proc near
             push ebp                                                        ;0x008767ac :        55
             mov ebp , esp                                                   ;0x008767ad :        8bec
             sub esp , 0104h                                                 ;0x008767af :        81ec04010000
             mov eax ,  dword ptr [ Data937090 ]                             ;0x008767b5 :        a190709300
             mov  dword ptr [ ebp - 4 ] , eax                                ;0x008767ba :        8945fc
             mov  eax , dword ptr [ ebp + 8 ]                                ;0x008767bd :        8b4508
             mov  ecx , dword ptr [eax]                                      ;0x008767c0 :        8b08
             mov  eax , dword ptr [esi]                                      ;0x008767c2 :        8b06
             mov  dl , byte ptr [ ecx + eax ]                                ;0x008767c4 :        8a1401
             cmp dl , 07Bh                                                   ;0x008767c7 :        80fa7b
             push edi                                                        ;0x008767ca :        57
             jne Label876845                                                 ;0x008767cb :        7578


     ;
     ;                 ----------------------------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE CURLY BRACKETS SUBSTITUTION IN THE SEND OUTPUT DIRECTLY TO THE PRINTER COMMAND
     ;                                  March 2022
     ;                 ----------------------------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; The curly brackets substitution in the send output directly to the printer command.
     ;
     ; 2022/3/2, by ccb
     ;

             cmp dword ptr vfpa_sys9076_data,00h
             jne Label8767cd
             jmp Label876845


     Label8767cd ::
             inc eax                                                         ;0x008767cd :        40
             lea edi ,  dword ptr [ ecx + eax ]                              ;0x008767ce :        8d3c01
             mov  dword ptr [esi] , eax                                      ;0x008767d1 :        8906
             mov  dl , byte ptr [edi]                                        ;0x008767d3 :        8a17
             cmp dl , 07Bh                                                   ;0x008767d5 :        80fa7b
             jne Label8767e6                                                 ;0x008767d8 :        750c
             cmp  byte ptr [ edi + 1 ] , 07Dh                                ;0x008767da :        807f017d
             jne Label876841                                                 ;0x008767de :        7561
             mov  byte ptr [ebx] , dl                                        ;0x008767e0 :        8813
             inc  dword ptr [esi]                                            ;0x008767e2 :        ff06
             jmp Label876847                                                 ;0x008767e4 :        eb61

     Label8767e6 ::
             cmp dl , 07Dh                                                   ;0x008767e6 :        80fa7d
             jne Label8767ef                                                 ;0x008767e9 :        7504
             mov  byte ptr [ebx] , dl                                        ;0x008767eb :        8813
             jmp Label876847                                                 ;0x008767ed :        eb58

     Label8767ef ::
             mov  dword ptr [ ebp + 8 ] , eax                                ;0x008767ef :        894508
             xor edi , edi                                                   ;0x008767f2 :        33ff

     Label8767f4 ::
             cmp edi , 0FFh                                                  ;0x008767f4 :        81ffff000000
             jnb Label876841                                                 ;0x008767fa :        7345
             cmp  eax , dword ptr [ ebp + 12 ]                               ;0x008767fc :        3b450c
             jnb Label876841                                                 ;0x008767ff :        7340
             movzx edx ,byte ptr [ eax + ecx ]                               ;0x00876801 :        0fb61408
             mov  dl , byte ptr [ edx + offset Data9375a0 ]                           ;0x00876805 :        8a92a0759300
             inc eax                                                         ;0x0087680b :        40
             mov  byte ptr [ ebp + edi + 0FFFFFEFCh ] , dl                   ;0x0087680c :        88943dfcfeffff
             mov edx , eax                                                   ;0x00876813 :        8bd0
             mov  dword ptr [esi] , eax                                      ;0x00876815 :        8906
             inc edi                                                         ;0x00876817 :        47
             cmp  byte ptr [ ecx + edx ] , 07Dh                              ;0x00876818 :        803c117d
             jne Label8767f4                                                 ;0x0087681c :        75d6
             sub  eax , dword ptr [ ebp + 8 ]                                ;0x0087681e :        2b4508
             mov  byte ptr [ ebp + edi + 0FFFFFEFCh ] , 00h                  ;0x00876821 :        c6843dfcfeffff00
             push eax                                                        ;0x00876829 :        50
             lea eax ,  dword ptr [ ebp + 0FFFFFEFCh ]                       ;0x0087682a :        8d85fcfeffff
             push eax                                                        ;0x00876830 :        50
             call Fun876718                                                  ;0x00876831 :        e8e2feffff
             cmp  dword ptr [ Data947aa4 ] , 00h                             ;0x00876836 :        833da47a940000
             mov  byte ptr [ebx] , al                                        ;0x0087683d :        8803
             je Label876847                                                  ;0x0087683f :        7406

     Label876841 ::
             xor eax , eax                                                   ;0x00876841 :        33c0
             jmp Label87684c                                                 ;0x00876843 :        eb07

     Label876845 ::
             mov  byte ptr [ebx] , dl                                        ;0x00876845 :        8813

     Label876847 ::
             inc  dword ptr [esi]                                            ;0x00876847 :        ff06
             xor eax , eax                                                   ;0x00876849 :        33c0
             inc eax                                                         ;0x0087684b :        40

     Label87684c ::
             mov  ecx , dword ptr [ ebp - 4 ]                                ;0x0087684c :        8b4dfc
             pop edi                                                         ;0x0087684f :        5f
             call Fun42bf1d                                                  ;0x00876850 :        e8c856bbff
             leave                                                           ;0x00876855 :        c9
             ret 08h                                                         ;0x00876856 :        c20800


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

     2, foxite.com:
     https://www.foxite.com/archives/chr123-fails-why-0000243023.htm

     3, wikis.com:
     http://fox.wikis.com/wc.dll?Wiki~VfpCommandQuestionMarkQuestionMarkQuestionMark

     4, sunyear.com.tw:
     http://vfp.sunyear.com.tw/viewtopic.php?t=6430
     http://vfp.sunyear.com.tw/viewtopic.php?t=7128


6. OTHER:

     For reference only, there is no guarantees.

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