QB 4.0 ERROR: Length incorrect with certain string variables
Posted: Tue Jan 05, 2021 12:59 am
I have confirmed this on two instances that an incorrect value is returned each time in both Qbasic 1.1 and QuickBasic 4.0. The code is this:
To make this bug happen, the variable name being set for the return value of the function (excluding dollar sign) must be the same as the one declared as a shared fixed string in the mainline program. In this case, I used v.
If shared is removed from DIM then the correct answer is returned.
I have not tested this on QuickBasic 4.5 or later.
Code: Select all
DIM SHARED v as STRING * 100
PRINT LEN(want$) 'Prints 100 instead of 3!!!
FUNCTION want$
v$="123"
want$=v$
END FUNCTION
If shared is removed from DIM then the correct answer is returned.
I have not tested this on QuickBasic 4.5 or later.