Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
string length question
#1
This isn't really affecting a program of mine, but I'm a nerd and therefore curious.

The QB Help for "Data Types" says that string variables can store over 32,000 characters, but I tried making a loop that adds characters to a blank string and it pooped out at 17,817 characters.

Is this a common error, or am I missing something?

*peace*

Meg.
Reply
#2
.
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#3
AFAIK the strings can't be DYNAMIC in QB. If you make a DYNAMIC array of strings you move the descriptor array outside the data segment,but the strings are still in.

Strings are in the 64K data segment of QB, as the static arrays, the global variables, the local variables, the stack, and -if compiled- the DATA statements. Don't know if file buffers are also included.All this must fit in 64K of space.

QB 7.1 -PDS offers the possibility of making the strings FAR, this moves the strings to a separate 64K segment.
Antoni
Reply
#4
I tried both with and without '$DYNAMIC. It stops at the same #: 17,817. Try it yourself. See if it's the same. This is interesting.

*peace*

Meg.
Reply
#5
The "prog" was:

FOR k& = 1 TO 33000
CLS
PRINT k&
S$ = S$ + " "
NEXT k&

strange the value changes from one configuration to another...

I will check with a log file to tell you the exact limit.

'll be right back
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#6
...
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#7
being dynamic. '$DYNAMIC has "side effects". I was in fact allowed to make a longer string when I used '$DYNAMIC. I got over 30,000 characters with it and only over 23,000 without it. (I also got different results when I booted into DOS and tried it that way.) I vaguely remember finding out back in the prehistoric days that QB had a problem actually realizing its stated limit of 32,767 characters per string. (I just didn't really need to do it bad enough to worry about why.)
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply
#8
You can do a$=space$(32767) without any problem in any QB configuration, even with QB 1.1

The problem with S$=S$+" " could be qb is making first a temp string, then copies S$ and " " into the new string, then assigns the temp string to s$ and erases old s$. So there are two long strings that must fit into the 64k data segment, along with other things as the stack and your other variables.

Also running from the IDE or compiled can make a difference: if I run PRINT FRE(0) I get 47442 bytes in the IDE and 61784 bytes compiled: the IDE uses part of the data segment to store it's own internal data.
Antoni
Reply
#9
Your explanation sounds logical, Antoni.

The longuest word in french is "anticonstitutionellement"... 24 letters, that fits a QB string :king:
hink Global, Make Symp' All ! ®
[Image: Banner.gif]
Reply
#10
(Well, that'll hopefully be enough nitpicking to last me at least a week. I feel better now.) '$DYNAMIC could've conceivably helped by causing *other* data to be stored elsewhere, possibly freeing up the one "64K data segment."
ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)