[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 2016-12-11T13:33:01-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/4282 2016-12-11T13:33:01-05:00 2016-12-11T13:33:01-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=24495#p24495 <![CDATA[Re: Bug: "Out of String Space" bug Found in "Palindromotron" program]]>
The string length never changes each GOTO...that caused Out of String Space error.

Your comment apostrophe was not correct character '

Code:

Again:CLSCOLOR 15, 1PRINT "=================================="PRINT "   ===========      ==========="PRINT "      === Palindromotron ==="PRINT "   ===========      ==========="PRINT "=================================="COLOR 7, 0PRINT "This program is capable of reversing"PRINT "words, sentences or entire texts."DIM TheString AS STRINGDIM EndString AS STRINGINPUT "Please enter some text:", TheStringTheString = LTRIM$(RTRIM$(TheString))IF LEN(TheString) = 0 THEN GOTO AgainGOSUB Reversestring  PRINT "This is it, reversed: "; EndStringPRINTEnterAgain:PRINT "Do you want to enter some text again? (y/n)"INPUT "(y/n):", Choice$Choice$ = UCASE$(LTRIM$(RTRIM$(UCASE$(Choice$))))IF Choice$ = "Y" THEN GOTO Again ELSE END                                               Reversestring:'this function can actually be made much better using FOR or WHILE'but since you haven`t had them yet, I do it with GOTOCurrentPos = LEN(TheString)NextChar:EndString = EndString + MID$(TheString, CurrentPos, 1)CurrentPos = CurrentPos - 1 'decrease CurrentPos with 1IF CurrentPos <> 0 THEN GOTO NextCharRETURN  ' used by Reversestring only as a GOSUB

Statistics: Posted by burger2227 — Sun Dec 11, 2016 1:33 pm


]]>
2016-12-11T06:19:31-05:00 2016-12-11T06:19:31-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=24492#p24492 <![CDATA[Bug: "Out of String Space" bug Found in "Palindromotron" program]]> Tutorial:(Beginners & newbies Edition) by Neo Deus Ex Machina
Chapter: Modifiers & Structure (IV)
Program: Chapter Program "Palindromotron":

Here is the full Code as presented in the pdf:

Code:

Again:CLSCOLOR 15, 1PRINT “==================================”PRINT “   ===========      ===========”PRINT “      === Palindromotron ===”PRINT “   ===========      ===========”PRINT “==================================”COLOR 7, 0PRINT “This program is capable of reversing”PRINT “words, sentences or entire texts.”DIM TheString AS STRING, EndString AS STRINGINPUT “Please enter some:”, TheStringTheString = LTRIM$(RTRIM$(TheString))IF LEN(TheString) = 0 THEN GOTO AgainGOSUB reversestringPRINT “This is it, reversed: ”; EndStringPRINTEnterAgain:PRINT “Do you want to enter some text again? (y/n)”INPUT “(y/n):”, choice$Choice$ = LTRIM$(RTRIM$(UCASE$(choice$)))IF Choice$ = “Y” THEN GOTO AgainIF Choice$ = “N” THEN END‘the program will only get here if Choice$ ≠ “Y” AND Choice$ ≠ “N”GOTO EnterAgainReversestring:‘this function can actually be made much better using FOR or WHILE‘but since you haven‘t had them yet, I do it with GOTONextChar:CurrentPos = LEN(TheString)EndString = EndString + MID$(TheString, CurrentPos, 1)CurrentPos = CurrentPos – 1‘decrease CurrentPos with 1IF CurrentPos <> 0 THEN GOTO NextCharRETURN
Bug: The problem is with this line CurrentPos = LEN(TheString) in the NextChar: sub-routine. It is causing the string buffer to continuously fill up with the letter at the end of the string, until you get the error warning, "out of string space.

Fix: Set CurrentPos only once, before the NextChar sub-routine:

Code:

CurrentPos = LEN(TheString)NextChar:EndString = EndString + MID$(TheString, CurrentPos, 1)CurrentPos = CurrentPos – 1‘decrease CurrentPos with 1IF CurrentPos <> 0 THEN GOTO NextChar

Statistics: Posted by Webbmaster1 — Sun Dec 11, 2016 6:19 am


]]>