[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2021-01-05T10:47:47-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/14850 2021-01-05T10:47:47-05:00 2021-01-05T10:47:47-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=39028#p39028 <![CDATA[Re: QB 4.0 ERROR: Length incorrect with certain string variables]]>

Code:

DIM v AS STRING * 50v = "Fifty"PRINT "*";STRING$(50, "-");"*"PRINT "*";v;"*"
Consider the following:

Code:

DECLARE FUNCTION var% (variable%)DIM SHARED dummy AS INTEGERdummy = 50PRINT var%(10)FUNCTION var% (variable%)var% = variable% + dummy%END FUNCTION
You expected QB to make a difference between v (an explicitly defined, shared fixed-length string) and v$ (an implicit, local, variable-length string)? The shared variable has precedent. You could RTRIM it before obtaining the length (but then, you'd get the length of the temporary string created by RTRIM...)

Statistics: Posted by MikeHawk — Tue Jan 05, 2021 10:47 am


]]>
2021-01-05T00:59:44-05:00 2021-01-05T00:59:44-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=39027#p39027 <![CDATA[QB 4.0 ERROR: Length incorrect with certain string variables]]> an incorrect value is returned each time in both Qbasic 1.1 and QuickBasic 4.0. The code is this:

Code:

DIM SHARED v as STRING * 100PRINT LEN(want$) 'Prints 100 instead of 3!!!FUNCTION want$v$="123"want$=v$END FUNCTION
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.

Statistics: Posted by mikefromca — Tue Jan 05, 2021 12:59 am


]]>