---------------------------------------------------------------------------------
                      VFP 9.0 FIX - THE MAXIMUM NUMBER OF FUNCTIONS FOR THE CALCULATE COMMAND
                                 January 2020
                 ---------------------------------------------------------------------------------
                                    CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), the maximum number of functions for the CALCULATE command is 64,
     the maximum number of functions (and variables) for the CALCULATE command with the TO VarList clause is 32,
     now the maximum number of functions for the CALCULATE command is 256.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Fun44eb32 :: ; proc near
             push ebp                                                        ;0x0044eb32 :        55
             mov ebp , esp                                                   ;0x0044eb33 :        8bec
             sub esp , 024h                                                  ;0x0044eb35 :        83ec24
             push ebx                                                        ;0x0044eb38 :        53
             push esi                                                        ;0x0044eb39 :        56
             push edi                                                        ;0x0044eb3a :        57
             mov edi , eax                                                   ;0x0044eb3b :        8bf8
             mov eax ,  dword ptr [ Data9393ac ]                             ;0x0044eb3d :        a1ac939300
             cmp  byte ptr [eax] , 028h                                      ;0x0044eb42 :        803828
             mov ebx , ecx                                                   ;0x0044eb45 :        8bd9
             mov esi , edx                                                   ;0x0044eb47 :        8bf2
             jne Label44eb7b                                                 ;0x0044eb49 :        7530
             inc eax                                                         ;0x0044eb4b :        40
             cmp  byte ptr [eax] , 04h                                       ;0x0044eb4c :        803804
             mov dword ptr [ Data9393ac ] ,  eax                             ;0x0044eb4f :        a3ac939300
             je Label608007                                                  ;0x0044eb54 :        0f84ad941b00
             xor edi , edi                                                   ;0x0044eb5a :        33ff

     Label44eb5c ::
             pushd 0FFFFFFFFh                                                ;0x0044eb5c :        6aff
             mov edx , 0400h                                                 ;0x0044eb5e :        ba00040000
             mov ecx , esi                                                   ;0x0044eb63 :        8bce
             call Fun421184                                                  ;0x0044eb65 :        e81a26fdff
             mov eax ,  dword ptr [ Data9393ac ]                             ;0x0044eb6a :        a1ac939300
             inc  word ptr [ebx]                                             ;0x0044eb6f :        66ff03
             cmp  byte ptr [eax] , 07h                                       ;0x0044eb72 :        803807
             je Label4425a2                                                  ;0x0044eb75 :        0f84273affff

     Label44eb7b ::
             pop edi                                                         ;0x0044eb7b :        5f
             pop esi                                                         ;0x0044eb7c :        5e
             pop ebx                                                         ;0x0044eb7d :        5b
             leave                                                           ;0x0044eb7e :        c9
             ret                                                             ;0x0044eb7f :        c3

     Label4425a2 ::
             inc  dword ptr [ Data9393ac ]                                   ;0x004425a2 :        ff05ac939300
             inc edi                                                         ;0x004425a8 :        47
             add esi , 018h                                                  ;0x004425a9 :        83c618


     ;
     ;                 ---------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE MAXIMUM NUMBER OF FUNCTIONS FOR THE CALCULATE COMMAND
     ;                                December 2019
     ;                 ---------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9, the maximum number of functions for the CALCULATE command is 64,
     ; the maximum number of functions (and variables) for the CALCULATE command with the TO VarList clause is 32,
     ; now the maximum number of functions for the CALCULATE command is 256.
     ;
     ; 2019/12/28, by ccb
     ;

     ;         cmp edi , 020h                                                  ;0x004425ac :        83ff20
             cmp edi , 0100h                                                  ;0x004425ac :        83ff20


             jnl Label44eb7b                                                 ;0x004425af :        0f8dc6c50000
             jmp Label44eb5c                                                 ;0x004425b5 :        e9a2c50000

     Label608007 ::
             inc eax                                                         ;0x00608007 :        40
             pushd 0FFFFFFFFh                                                ;0x00608008 :        6aff
             mov edx , 0400h                                                 ;0x0060800a :        ba00040000
             lea ecx ,  dword ptr [ ebp - 36 ]                               ;0x0060800f :        8d4ddc
             mov dword ptr [ Data9393ac ] ,  eax                             ;0x00608012 :        a3ac939300
             call Fun421184                                                  ;0x00608017 :        e86891e1ff
             test eax , eax                                                  ;0x0060801c :        85c0
             je Label60803d                                                  ;0x0060801e :        741d
             lea ebx ,  dword ptr [ ebp - 36 ]                               ;0x00608020 :        8d5ddc
             call Fun4ed9d7                                                  ;0x00608023 :        e8af59eeff
             pushd 018h                                                      ;0x00608028 :        6a18
             mov edx , ebx                                                   ;0x0060802a :        8bd3
             mov ecx , esi                                                   ;0x0060802c :        8bce
             call Fun42c19b                                                  ;0x0060802e :        e86841e2ff
             mov  eax , dword ptr [ esi + 12 ]                               ;0x00608033 :        8b460c
             mov  dword ptr [edi] , eax                                      ;0x00608036 :        8907
             jmp Label44eb7b                                                 ;0x00608038 :        e93e6be4ff

     Label60803d ::
             mov  eax , dword ptr [ ebp - 36 ]                               ;0x0060803d :        8b45dc
             or  dword ptr [ esi + 4 ] , 0FFFFFFFFh                          ;0x00608040 :        834e04ff
             mov  dword ptr [esi] , eax                                      ;0x00608044 :        8906
             xor eax , eax                                                   ;0x00608046 :        33c0
             inc eax                                                         ;0x00608048 :        40
             pushd 00h                                                       ;0x00608049 :        6a00
             mov  word ptr [ esi + 10 ] , ax                                 ;0x0060804b :        6689460a
             mov  dword ptr [edi] , eax                                      ;0x0060804f :        8907
             and  dword ptr [ esi + 16 ] , 00h                               ;0x00608051 :        83661000
             push esi                                                        ;0x00608055 :        56
             mov  dword ptr [ esi + 12 ] , eax                               ;0x00608056 :        89460c
             call Fun5007ab                                                  ;0x00608059 :        e84d87efff
             jmp Label44eb7b                                                 ;0x0060805e :        e9186be4ff


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, mail-archive.com:
     https://www.mail-archive.com/profox@leafe.com/msg143918.html


6. OTHER:

     For reference only, there is no guarantees.

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