Using Very large programs


Sometimes VFP users create programs that are very large. The limit in earlier versions of VFP was about 64k for a compiled program size. VFP9 allows much larger programs.


The code below creates a simple program with a CASE statement, verifies the result, and shows the compiled code size.


 


In VFP8, I was able to run the code with n=286 (fxp size 61,511) successfully. Anything larger failed with “Program Too Large”


In VFP9, setting n=41,719 (fxp size 8,928,173) succeeded. If I change the ProgCache setting in my config.fpw: PROGCACHE=0, then it would succeed at 1,000,000 (fxp size 214,000,307). Let me know how big you can make it on your machine!


 


So, programs that are several thousand times larger can be handled by VFP9!


 


See also SYS(3065) Internal Program Cache


 


The generated program looks like this for n=2


 


y=’a’ && this is used in a CASE statement *way* down there


Do Case


Case Y = ‘a’


      x=”aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”


      x=”aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”


      y=”b”


Case .T.   


      x=”aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”


      x=”aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”


      y = “a”


ENDCASE


set compatible on


IF y=”b” then


      cret= “DOCASE:PASS “+TRANSFORM(FSIZE(“tt2.prg”))


ELSE


      cret= “DOCASE:FAIL “+TRANSFORM(FSIZE(“tt2.prg”))


endif


set compatible off


return cret


 


 


 


 


This is the large program code generator:


 


 


n=1000000   && 214,000,307


&& VFP8: 286 yields FXP size 61,511. 287 fails


&& VFP9:  41719 yields FXP size 8,928,173. 41720 fails due to ProgCache size


 


SET TEXTMERGE TO tt2.prg  on noshow


      \y=’a’ && this is used in a CASE statement *way* down there


      \Do Case


      \Case Y = ‘a’


      FOR i = 1 TO n


            \     x=”<<REPLICATE(“a”,100)>>”


      ENDFOR


\     y=”b”


\Case .T.   


      FOR i = 1 TO n


            \     x=”<<REPLICATE(“a”,100)>>”


      ENDFOR


     


\     y = “a”


\ENDCASE


\set compatible on


\IF y=”b” then


\     cret= “DOCASE:PASS “+TRANSFORM(FSIZE(“tt2.prg”))


\ELSE


\     cret= “DOCASE:FAIL “+TRANSFORM(FSIZE(“tt2.prg”))


\endif     


\set compatible off


\return cret


SET TEXTMERGE to


COMPILE tt2


?tt2()


 


 


RETURN

Comments (5)

  1. Garry Bettle says:

    Hi Calvin,

    I managed to get it to run with:

    n= 1189128

    The prg is 263,986,744 bytes and the

    fxp is 273,499,894 bytes.

    Cheers,

    Garry

  2. When you write code in any computer language, there are common constructs that alter the flow of control,…

  3. A customer asked

    1) Is it better to set it to 0 (Auto) or some &quot;larger&quot; number, such as -16 (1024kb).&amp;nbsp;…