Qbasicnews.com

Full Version: I found a QB4.5 BUG/feature!!!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Try this:

Code:
DIM s(32767) AS STRING * 1

It works, even though there should be, according to QB's specifications, 32768 bytes alloted for strings.

HOWEVER, if you do "PRINT s(0)", you will get an error, because qb "automatically" sets the starting index to 1!!
What would an array like that have anything to do with the number of bytes qb allots for strings? That's an integer array, not a string array. The only connection I can think of is that QB might store the array descriptor in DGROUP.

I'll test whether PRINT(0) causes an error as soon as I can reboot into Windows and run QB.
It's a string array.

One thing I forgot to add is "*1"... updating initial post.

Anonymous

also interesting:

Code:
DIM r(32766) AS STRING * 1

FOR a = 0 TO 32766
r(a) = "a"
NEXT
PRINT r(0)

runs without an error, even though it assigns 32767 subscripts to an array with 32766! what the?!
you dimmed the array with 32767 subscripts...

Anonymous

holy crap plas-man i never knew that arrays had one extra subscript for 0.. holy nuts you learn somethin new everyday i guess
Well, the bug isn't that it runs without an error when the subscript is 0, but that "s1(32767) AS STRING * 1" means, all the other time, "s1(0 to 32767) AS STRING * 1", but this time it means s1(1 to 32767).....
$hit! One more bug in QB =P
qb counts on 0 or 1?
QB always counts from 0.
Pages: 1 2