Microsoft KB Archive/27489

= &quot;Out of String Space,&quot; Dynamic Array of Fixed-Length Strings =

Article ID: 27489

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS

-



This article was previously published under Q27489



SUMMARY
When running the program below inside the QuickBasic Version 4.00, 4.00b, or 4.50 environment, an &quot;Out of String Space&quot; error is generated after fewer than 70 iterations of concatenating a variable length string onto a fixed-length string array element. However, the FRE(&quot;&quot;) and FRE(-1) functions both return the same value all the way through the loop. Note that the fixed-length string array element is part of a dynamic array, which puts it in the far heap; therefore, it normally does not use up any of the normal string space in the default data segment.

The program below demonstrates an internal limitation of the QB.EXE interpreter that is rarely encountered. Microsoft currently does not plan to change this limitation.



MORE INFORMATION
Note that fixed-length strings are not supported by QuickBasic versions earlier than Version 4.00.

As a workaround, please note that the problem only occurs inside the QuickBasic Version 4.00 editor. When compiled to an .EXE file, the sample program works properly.

The problem is that QuickBasic assumes that a far fixed-length string will always stay far. The Basic run-time routines must have the string in DGROUP to manipulate it with string functions like LTRIM$ and RTRIM$.

LTRIM$ and RTRIM$ require two copies of the string at one point, and the program eventually runs out of string space in the default data segment, DGROUP. This behavior also occurs in a version of the program compiled with BC /O if the strings are made longer. This limitation of Basic is inherent in its construction, and Microsoft currently has no plans to change this construction.

The following is a code example: REM $DYNAMIC DIM srv(0) AS STRING * 28000 abc$ = STRING$(330,&quot;0&quot;) srv(0) = abc$ FOR t = 1 TO 79 srv(0) = RTRIM$(srv(0)) + abc$ PRINT t, LEN(RTRIM$(srv(0))), FRE(&quot;&quot;), FRE(-1) NEXT T

Additional query words: QuickBas BasicCom

Keywords: KB27489

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.