-----------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - THE DEFAULT VALUE FOR THE SET SYSFORMATS COMMAND
                                   May 2021
                 -----------------------------------------------------------------------------------
                                     CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), sometimes the default value is ON for the SET SYSFORMATS command,
     now the default value is always OFF for the SET SYSFORMATS command.

     The bug only occurs for a private data session in DBCS (Double-Byte Character Sets) environments.


2. CAUSE:

     For the system data session (DataSessionID=0), 
     the default value is OFF for the SET SYSFORMATS command.

     For the default data session (DataSessionID=1),
     the default value is OFF for the SET SYSFORMATS command.

     In vfp9 (and vfp6, vfp7, vfp8),
     for a private data session (DataSessionID>=2),
     the default value is OFF for the SET SYSFORMATS command in non-DBCS (Double-Byte Character Sets),
     but the default value is ON for the SET SYSFORMATS command in DBCS (Double-Byte Character Sets).

     In VFP Advanced,
     for a private data session (DataSessionID>=2),
     the default value is always OFF for the SET SYSFORMATS command.

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label414dbe ::
             mov  ecx , dword ptr [ Data9370f4 ]                             ;0x00414dbe :        8b0df4709300
             mov eax ,  dword ptr [ Data935778 ]                             ;0x00414dc4 :        a178579300
             shr ecx , 0Ch                                                   ;0x00414dc9 :        c1e90c
             shr eax , 03h                                                   ;0x00414dcc :        c1e803
             and cl , 01h                                                    ;0x00414dcf :        80e101
             pushd 05Ah                                                      ;0x00414dd2 :        6a5a
             add eax , 05h                                                   ;0x00414dd4 :        83c005
             mov  dword ptr [ esi + 0ECh ] , ebx                             ;0x00414dd7 :        899eec000000
             mov  dword ptr [ esi + 0F0h ] , ebx                             ;0x00414ddd :        899ef0000000
             mov  dword ptr [ esi + 0F4h ] , 032h                            ;0x00414de3 :        c786f400000032000000
             mov  dword ptr [ esi + 0FCh ] , ebx                             ;0x00414ded :        899efc000000
             mov  dword ptr [ esi + 0100h ] , ebx                            ;0x00414df3 :        899e00010000
             mov  dword ptr [ esi + 0F8h ] , edi                             ;0x00414df9 :        89bef8000000
             mov  byte ptr [ esi + 0104h ] , 02Eh                            ;0x00414dff :        c686040100002e
             mov  dword ptr [ esi + 0108h ] , ebx                            ;0x00414e06 :        899e08010000
             mov  byte ptr [ esi + 0114h ] , 02Ch                            ;0x00414e0c :        c686140100002c
             mov  dword ptr [ esi + 011Ch ] , ebx                            ;0x00414e13 :        899e1c010000
             mov  byte ptr [ esi + 0148h ] , 024h                            ;0x00414e19 :        c6864801000024
             mov  byte ptr [ esi + 0149h ] , bl                              ;0x00414e20 :        889e49010000


     ;
     ;                 ------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE DEFAULT VALUE FOR THE SET SYSFORMATS COMMAND
     ;                                   May 2021
     ;                 ------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, sometimes the default value is ON for the SET SYSFORMATS command,
     ; now the default value is always OFF for the SET SYSFORMATS command.
     ;
     ; 2021/5/26, by ccb
     ;

     ;         mov  byte ptr [ esi + 0120h ] , cl                              ;0x00414e26 :        888e20010000
             mov  byte ptr [ esi + 0120h ] , 00h                              ;0x00414e26 :        888e20010000


             mov  dword ptr [ esi + 0158h ] , ebx                            ;0x00414e2c :        899e58010000
             mov  dword ptr [ esi + 015Ch ] , ebx                            ;0x00414e32 :        899e5c010000
             mov  dword ptr [ esi + 0160h ] , ebx                            ;0x00414e38 :        899e60010000
             mov  byte ptr [ esi + 0152h ] , bl                              ;0x00414e3e :        889e52010000
             call Fun42bf2a                                                  ;0x00414e44 :        e8e1700100
             cmp eax , ebx                                                   ;0x00414e49 :        3bc3
             mov  dword ptr [ ebp - 16 ] , eax                               ;0x00414e4b :        8945f0
             je Label61a3f1                                                  ;0x00414e4e :        0f849d552000
             mov  eax , dword ptr [eax]                                      ;0x00414e54 :        8b00
             mov  ecx , dword ptr [ eax - 4 ]                                ;0x00414e56 :        8b48fc
             sub ecx , 0Ch                                                   ;0x00414e59 :        83e90c
             mov  dword ptr [ ebp + 8 ] , ecx                                ;0x00414e5c :        894d08
             mov edx , ecx                                                   ;0x00414e5f :        8bd1
             mov  dword ptr [ ebp - 12 ] , eax                               ;0x00414e61 :        8945f4
             lea edi ,  dword ptr [ eax + 4 ]                                ;0x00414e64 :        8d7804
             shr ecx , 02h                                                   ;0x00414e67 :        c1e902
             xor eax , eax                                                   ;0x00414e6a :        33c0
             mov  dword ptr [ ebp - 4 ] , edi                                ;0x00414e6c :        897dfc
             rep stosd                                                       ;0x00414e6f :        f3ab
             mov ecx , edx                                                   ;0x00414e71 :        8bca
             and ecx , 03h                                                   ;0x00414e73 :        83e103
             rep stosb                                                       ;0x00414e76 :        f3aa
             mov  ecx , dword ptr [ ebp - 12 ]                               ;0x00414e78 :        8b4df4
             mov eax , edx                                                   ;0x00414e7b :        8bc2
             lea eax ,  dword ptr [ 8 * eax + 0FFFFFFFFh ]                   ;0x00414e7d :        8d04c5ffffffff
             mov  dword ptr [ecx] , eax                                      ;0x00414e84 :        8901
             mov  ecx , dword ptr [ ebp - 4 ]                                ;0x00414e86 :        8b4dfc
             mov edx , eax                                                   ;0x00414e89 :        8bd0
             sar edx , 03h                                                   ;0x00414e8b :        c1fa03
             and eax , 07h                                                   ;0x00414e8e :        83e007
             add ecx , edx                                                   ;0x00414e91 :        03ca
             mov  dl , byte ptr [ eax + offset Data91fbd8 ]                           ;0x00414e93 :        8a90d8fb9100
             or  byte ptr [ecx] , dl                                         ;0x00414e99 :        0811
             mov  eax , dword ptr [ ebp - 16 ]                               ;0x00414e9b :        8b45f0


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_vfp9fix11.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix174.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix176.asp

     2, sunyear.com.tw:
     http://vfp.sunyear.com.tw/viewtopic.php?t=7063


6. OTHER:

     For reference only, there is no guarantees.

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