<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>Guessing game optimize</title>
		<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize</link>
		<description>Posts in the discussion thread &quot;Guessing game optimize&quot; - My first program ever!!!! Need help :’(</description>
				<copyright></copyright>
		<lastBuildDate>Wed, 11 Mar 2026 15:53:00 +0000</lastBuildDate>
		
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646393</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646393</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 18:34:31 +0000</pubDate>
				<wikidot:authorName>Trenly</wikidot:authorName>				<wikidot:authorUserId>1905506</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Actually, I am using Goto a lot inside of a physics program I am working on. However, I am making the menus on the graph screen. The insane amount of conditionals and the size required for this program means that I have to avoid memory leaks as I code. I find it very useful to apply that same thinking of preventing them in the first place to any program I make</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646392</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646392</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 18:30:18 +0000</pubDate>
				<wikidot:authorName>Trenly</wikidot:authorName>				<wikidot:authorUserId>1905506</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>the T and W are being used as flags. T is the flag I used for &quot;Test&quot; . When comparing B to A, it sets it to 0 once it finds the correct value. This prevents anything from being accidentally executed. I didn't need to add it as many times as I did, but I added it to prevent B&gt;A from executing when B&gt;100 since I removed the Goto after each statement.</p> <p>The W is a flag to see if you won or not, again it was added to prevent memory leaks and shorten the code</p> <hr /> <p>Edit: Made a few minor changes and commented the code. I used asterisks in my comments as a way of visualizing where a memory leak may occur. If you see a &quot;<em>*Goto label &quot; or &quot;</em>**Goto label &quot;&quot; or any number of asterisks, it is inside a conditional/loop or multiple condionals/loops that would cause a memory leak. I might also upload something showing tab notation later.</p> <div class="code"> <pre><code>Comment syntax: // Indicates a comment * Indicates it is inside a conditional or loop needing an end statement yet ** Indicates it is inside a conditional or loop, inside of a conditional or loop, and needs 2 end statements yet.</code></pre></div> <hr /> <p>Edit x2</p> <p>Here is what it would look like in tab notation. If a Goto is not all the way to the left, then you have a memory leak:</p> <div class="code"> <pre><code>ClrHome Lbl 0 SetUpEditor ʟSCO //Create or unarchive the list, error prevention 3→dim(ʟSCO //set the length of the list to 3, error prevention 0→W //Set it to know we haven't won this round Menu(&quot;Guess the number&quot;,&quot;Play&quot;,1,&quot;Highscores&quot;,2,&quot;Quit&quot;,3 Lbl 1 //Play Game 0→S //Set score to 0 ClrHome Output(3,1,&quot;Range is 1-100 //tell the player the range Pause ClrHome randInt(1,100→A //Generate our number Lbl 4 ClrHome Output(5,1,&quot;Guess //ask for their guess Input B //they input their guess S+1→S //Add 1 to their score 1→T //Reset the flag so we test both conditions ClrHome If T(B&gt;100):Then //IF THE GUESS IS OVER 100 0→T //Set the test flag to not test the other condition Output(3,7,&quot;!!!GUESS OUT!!! //Tell the user their guess is out of range Output(4,7,&quot;!!!OF RANGE.!!! Output(6,7,&quot;YOUR GUESS: Output(6,19,B Output(8,6,&quot;NUMBER LIMIT: 100 Output(10,2,&quot;PRESS ENTER TO TRY AGAIN End // End the conditional If B&lt;A:Then //IF THE GUESS IS LESS THAN A Output(5,9,&quot;TOO LOW! //Tell the user it is too low Output(10,2,&quot;PRESS ENTER TO TRY AGAIN End // End the conditional If T(B&gt;A):Then //IF B IS GREATER THAN A and IT IS NOT OVER 100 Output(5,8,&quot;!TOO HIGH! //Tell the user it is 100 High Output(10,2,&quot;PRESS ENTER TO TRY AGAIN End //End the conditional If B=A:Then //IF B EQUALS A 1→W //Set the flag so the program knows the game is won Output(5,6,&quot;!!YOU GOT IT !! //Tell the user they won Output(10,2,&quot;PRESS ENTER TO CONTINUE Pause ClrHome Output(4,9,&quot;SCORE: //Tell the user their Score Output(4,16,S Output(10,2,&quot;PRESS ENTER TO CONTINUE Pause ClrHome End //End the conditional If not(W:Goto 4 //If the game has not been won, goto where they enter their guess If sum(W(S&lt;ʟSCO //IF THE GAME HAS BEEN WON and THEIR SCORE IS GREATER THAN ANY HIGH SCORE Then Output(1,1,&quot;NEW HIGHSCORE!!! //Tell them they got a high score Output(3,1,&quot;PRESS ENTER TO SAVE SCORE Pause ClrHome Input Str4 //Have them input a highscore name sum(S&lt;ʟSCO→L //Find which scores they beat 4→dim(ʟSCO //Extend the length of the scores list by 1 For(E,0,L //FOR EACH ITEM from 0 to the number of scores we beat ʟSCO(3-E→ʟSCO(4-E //Move the item at the end of the list up 1 position, creating a gap for our high score End //End the for loop S→ʟSCO(L) //Insert our high score in the proper position If L=1 //If we got the third highest score Str4→Str3 //Store our name into the third string If L=2 //IF WE GOT THE SECOND HIGHEST SCORE Then Str2→Str3 //Store the second string to the third string Str4→Str2 //Store our name into the second string End //End the conditional If L=3:Then //IF WE GOT THE FIRST HIGHEST SCORE Str2→Str3 //Store the second string into the third string Str1→Str2 //Store the first string into the second string Str4→Str1 //Store our name into the first string End //End the conditional ClrHome Output(1,1,&quot;***HIGHSCORES*** //Display the highscores Output(2,1,&quot;NAME: Output(2,21,&quot;SCORE: Output(3,1,&quot;---------------- Output(4,1,&quot;1) Output(5,1,&quot;2) Output(6,1,&quot;3) Output(4,4,Str1 Output(5,4,Str2 Output(6,4,Str3 Output(4,24,ʟSCO(1) Output(5,24,ʟSCO(2) Output(6,24,ʟSCO(3) Output(8,8,&quot;BACK=ENTER End //End the conditional Pause //Wait for enter, this was put outside the conditional as a failsafe Goto 0 //Restart the game after we win, put outside the conditional to prevent memory leaks Lbl 2 //Display the highscores ClrHome Output(1,1,&quot;***HIGHSCORES*** Output(2,1,&quot;NAME: Output(2,21,&quot;SCORE: Output(3,1,&quot;---------------- Output(4,1,&quot;1) Output(5,1,&quot;2) Output(6,1,&quot;3) Output(4,4,Str1 Output(5,4,Str2 Output(6,4,Str3 Output(4,24,ʟSCO(1) Output(5,24,ʟSCO(2) Output(6,24,ʟSCO(3) Output(8,8,&quot;BACK=ENTER Pause Goto 0 Lbl 3 //Exit ClrHome Stop</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646385</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646385</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 18:14:03 +0000</pubDate>
				<wikidot:authorName>wifijoe</wikidot:authorName>				<wikidot:authorUserId>2922498</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>depends on how you use them. In this case, every Goto you are using to essentially loop the program takes it out of the If statement, which cause a memory leak. I did this a lot back then, don't worry. Goto, when used correctly, will not cause memory leaks. <span style="text-decoration: line-through;">I just wouldn't use them</span></p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646382</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646382</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 18:08:07 +0000</pubDate>
								<wikidot:authorUserId>3474380</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>So does a Goto command cause a memory leak?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646379</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646379</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 18:05:25 +0000</pubDate>
								<wikidot:authorUserId>3474380</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>What is the T and W for and what are they doing?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646339</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646339</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 16:48:23 +0000</pubDate>
				<wikidot:authorName>Trenly</wikidot:authorName>				<wikidot:authorUserId>1905506</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I came up with this, but haven't tested it:</p> <div class="code"> <pre><code>ClrHome Lbl 0 SetUpEditor ʟSCO //Create or unarchive the list, error prevention 3→dim(ʟSCO //set the length of the list to 3, error prevention 0→W //Set it to know we haven't won this round Menu(&quot;Guess the number&quot;,&quot;Play&quot;,1,&quot;Highscores&quot;,2,&quot;Quit&quot;,3 Lbl 1 //Play Game 0→S //Set score to 0 ClrHome Output(3,1,&quot;Range is 1-100 //tell the player the range Pause ClrHome randInt(1,100→A //Generate our number Lbl 4 ClrHome Output(5,1,&quot;Guess //ask for their guess Input B //they input their guess S+1→S //Add 1 to their score 1→T //Reset the flag so we test both conditions ClrHome If T(B&gt;100):Then //IF THE GUESS IS OVER 100 0→T //*Set the test flag to not test the other condition Output(3,7,&quot;!!!GUESS OUT!!! //*Tell the user their guess is out of range Output(4,7,&quot;!!!OF RANGE.!!! Output(6,7,&quot;YOUR GUESS: Output(6,19,B Output(8,6,&quot;NUMBER LIMIT: 100 Output(10,2,&quot;PRESS ENTER TO TRY AGAIN End // End the conditional If B&lt;A:Then //IF THE GUESS IS LESS THAN A Output(5,9,&quot;TOO LOW! //*Tell the user it is too low Output(10,2,&quot;PRESS ENTER TO TRY AGAIN End // End the conditional If T(B&gt;A):Then //IF B IS GREATER THAN A and IT IS NOT OVER 100 Output(5,8,&quot;!TOO HIGH! //*Tell the user it is 100 High Output(10,2,&quot;PRESS ENTER TO TRY AGAIN End //End the conditional If B=A:Then //IF B EQUALS A 1→W //*Set the flag so the program knows the game is won Output(5,6,&quot;!!YOU GOT IT !! //*Tell the user they won Output(10,2,&quot;PRESS ENTER TO CONTINUE Pause ClrHome Output(4,9,&quot;SCORE: //*Tell the user their Score Output(4,16,S Output(10,2,&quot;PRESS ENTER TO CONTINUE Pause ClrHome End //End the conditional If not(W:Goto 4 //If the game has not been won, goto where they enter their guess If sum(W(S&lt;ʟSCO //IF THE GAME HAS BEEN WON and THEIR SCORE IS GREATER THAN ANY HIGH SCORE Then Output(1,1,&quot;NEW HIGHSCORE!!! //*Tell them they got a high score Output(3,1,&quot;PRESS ENTER TO SAVE SCORE Pause ClrHome Input Str4 //*Have them input a highscore name sum(S&lt;ʟSCO→L //*Find which scores they beat 4→dim(ʟSCO //*Extend the length of the scores list by 1 For(E,0,L //*FOR EACH ITEM from 0 to the number of scores we beat ʟSCO(3-E→ʟSCO(4-E //**Move the item at the end of the list up 1 position, creating a gap for our high score End //*End the for loop S→ʟSCO(L) //*Insert our high score in the proper position If L=1 //*If we got the third highest score Str4→Str3 //*Store our name into the third string If L=2 //*IF WE GOT THE SECOND HIGHEST SCORE Then Str2→Str3 //**Store the second string to the third string Str4→Str2 //**Store our name into the second string End //*End the conditional If L=3:Then //*IF WE GOT THE FIRST HIGHEST SCORE Str2→Str3 //**Store the second string into the third string Str1→Str2 //**Store the first string into the second string Str4→Str1 //**Store our name into the first string End //*End the conditional ClrHome Output(1,1,&quot;***HIGHSCORES*** //*Display the highscores Output(2,1,&quot;NAME: Output(2,21,&quot;SCORE: Output(3,1,&quot;---------------- Output(4,1,&quot;1) Output(5,1,&quot;2) Output(6,1,&quot;3) Output(4,4,Str1 Output(5,4,Str2 Output(6,4,Str3 Output(4,24,ʟSCO(1) Output(5,24,ʟSCO(2) Output(6,24,ʟSCO(3) Output(8,8,&quot;BACK=ENTER End //End the conditional Pause //Wait for enter, this was put outside the conditional as a failsafe Goto 0 //Restart the game after we win, put outside the conditional to prevent memory leaks Lbl 2 //Display the highscores ClrHome Output(1,1,&quot;***HIGHSCORES*** Output(2,1,&quot;NAME: Output(2,21,&quot;SCORE: Output(3,1,&quot;---------------- Output(4,1,&quot;1) Output(5,1,&quot;2) Output(6,1,&quot;3) Output(4,4,Str1 Output(5,4,Str2 Output(6,4,Str3 Output(4,24,ʟSCO(1) Output(5,24,ʟSCO(2) Output(6,24,ʟSCO(3) Output(8,8,&quot;BACK=ENTER Pause Goto 0 Lbl 3 //Exit ClrHome Stop</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3646295</guid>
				<title>Re: Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3646295</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 15:30:37 +0000</pubDate>
				<wikidot:authorName>wifijoe</wikidot:authorName>				<wikidot:authorUserId>2922498</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Some trivial optimizations, I'll look for other stuff later</p> <div class="code"> <pre><code>:ClrHome :Lbl 0 :Menu(“Guess the number”,”Play”,1,”Highscores”,2,”Quit”,3 :Lbl 1 :0→S :ClrHome :Output(3,1,”Range is 1-100 :Pause :ClrHome :randInt(1,100→A :Lbl 4 :ClrHome :Output(5,1,”Guess :Input B :If B&gt;100:Then :S+1-&gt;S :ClrHome :Output(3,7,”!!!GUESS OUT!!! :Output(4,7,”!!!OF RANGE.!!! :Output(6,7,”YOUR GUESS: :Output(6,19,B :Output(8,6,”NUMBER LIMIT: 100 :Output(10,2,”PRESS ENTER TO TRY AGAIN :Pause :Goto 4 //memory leak :Else :If B&lt;A:Then :S+1-&gt;S :ClrHome :Output(5,9,”TOO LOW! :Output(10,2,”PRESS ENTER TO TRY AGAIN :Pause :Goto 4 //memory leak :Else :If B&gt;A:Then :S+1-&gt;S :ClrHome :Output(5,8,”!TOO HIGH! :Output(10,2,”PRESS ENTER TO TRY AGAIN :Pause :Goto 4 //memory leak :Else :If B=A:Then :S+1-&gt;S :ClrHome :Output(5,6,”!!YOU GOT IT !! :Output(10,2,”PRESS ENTER TO CONTINUE :Pause :ClrHome :Output(4,9,”SCORE: :Output(4,16,S :Output(10,2,”PRESS ENTER TO CONTINUE :Pause :ClrHome :If S&lt;lSCO3(1):Then :Goto 5 // memory leak :Else :Goto 0 :Lbl 5 :Output(1,1,”NEW HIGHSCORE!!! :Output(3,1,”PRESS ENTER TO SAVE SCORE :Pause :ClrHome :Input Str4 :If S&lt;lSCO1(1):Then :lSCO2(1)-&gt;lSCO3(1) :lSCO1(1)-&gt;lSCO2(1) :S-&gt;lSCO1(1) :Str2-&gt;Str3 :Str1-&gt;Str2 :Str4-&gt;Str1 :Goto 0 //memory leak :Else :Goto 6 :Lbl 6 :If S&lt;lSCO2(1):Then :lSCO2(1)-&gt;lSCO3(1) :S-&gt;lSCO2(1) :Str2-&gt;Str3 :Str4-&gt;Str2 :Else :Goto 7 :Lbl 7 :If S&lt;lSCO3(1):Then :S-&gt;lSCO3(1) :Str4-&gt;Str3 :Else :Goto 0 :Lbl 2 :ClrHome :Output(1,1,”********HIGHSCORES******** :Output(2,1,”NAME: :Output(2,21,”SCORE: :Output(3,1,”---------------------------- :Output(4,1,”1) :Output(5,1,”2) :Output(6,1,”3) :Output(4,4,Str1 :Output(5,4,Str2 :Output(6,4,Str3 :Output(4,24,lSCO1(1) :Output(5,24,lSCO2(1) :Output(6,24,lSCO3(1) :Output(9,8,”BACK=ENTER :Pause :Goto 0 :Lbl 3 :ClrHome :Stop</code></pre></div> <p>ok, there are a LOT of memory leaks here, mostly with the parts with where I pointed them out, but they are EVERYWHERE.<br /> Where are the end statements? That's more memory leak problems&#8230;<br /> Like I said, I'll look into when I get some free time</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-4412878#post-3645958</guid>
				<title>Guessing game optimize</title>
				<link>http://tibasicdev.wikidot.com/forum/t-4412878/guessing-game-optimize#post-3645958</link>
				<description></description>
				<pubDate>Tue, 05 Dec 2017 03:39:42 +0000</pubDate>
								<wikidot:authorUserId>3474380</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I need you guy’s help optimizingthis code and fixing the memory leaks in the program. Please help. I want to use it but not while it leaks memor, plus I want it to have the exact same features but possibly be a bit smaller.</p> <p>Here is the code:</p> <div class="code"> <pre><code>:ClrHome :Goto 0 :Lbl 0 :Menu(“GUESS THE NUMBER”,”PLAY”,1,”HIGHSCORES”,2,”QUIT”,3 :Lbl 1 :0-&gt;S :ClrHome :Output(3,1,”RANGE IS 1-100”) :Pause :ClrHome :randInt(1,100)-&gt;A :Goto 4 :Lbl 4 :ClrHome :Output(5,1,”GUESS”) :Input B :If B&gt;100:Then :S+1-&gt;S :ClrHome :Output(3,7,”!!!GUESS OUT!!!”) :Output(4,7,”!!!OF RANGE.!!!”) :Output(6,7,”YOUR GUESS: “) :Output(6,19,B) :Output(8,6,”NUMBER LIMIT: 100”) :Output(10,2,”PRESS ENTER TO TRY AGAIN”) :Pause :Goto 4 :Else :If B&lt;A:Then :S+1-&gt;S :ClrHome :Output(5,9,”TOO LOW!”) :Output(10,2,”PRESS ENTER TO TRY AGAIN”) :Pause :Goto 4 :Else :If B&gt;A:Then :S+1-&gt;S :ClrHome :Output(5,8,”!TOO HIGH!”) :Output(10,2,”PRESS ENTER TO TRY AGAIN”) :Pause :Goto 4 :Else :If B=A:Then :S+1-&gt;S :ClrHome :Output(5,6,”!!YOU GOT IT !!”) :Output(10,2,”PRESS ENTER TO CONTINUE”) :Pause :ClrHome :Output(4,9,”SCORE: “) :Output(4,16,S) :Output(10,2,”PRESS ENTER TO CONTINUE”) :Pause :ClrHome :If S&lt;lSCO3(1):Then :Goto 5 :Else :Goto 0 :Lbl 5 :Output(1,1,”NEW HIGHSCORE!!!”) :Output(3,1,”PRESS ENTER TO SAVE SCORE”) :Pause :ClrHome :Input Str4 :If S&lt;lSCO1(1):Then :lSCO2(1)-&gt;lSCO3(1) :lSCO1(1)-&gt;lSCO2(1) :S-&gt;lSCO1(1) :Str2-&gt;Str3 :Str1-&gt;Str2 :Str4-&gt;Str1 :Goto 0 :Else :Goto 6 :Lbl 6 :If S&lt;lSCO2(1):Then :lSCO2(1)-&gt;lSCO3(1) :S-&gt;lSCO2(1) :Str2-&gt;Str3 :Str4-&gt;Str2 :Else :Goto 7 :Lbl 7 :If S&lt;lSCO3(1):Then :S-&gt;lSCO3(1) :Str4-&gt;Str3 :Else :Goto 0 :Lbl 2 :ClrHome :Output(1,1,”********HIGHSCORES********”) :Output(2,1,”NAME:”) :Output(2,21,”SCORE:”) :Output(3,1,”----------------------------“) :Output(4,1,”1)”) :Output(5,1,”2)”) :Output(6,1,”3)”) :Output(4,4,Str1) :Output(5,4,Str2) :Output(6,4,Str3) :Output(4,24,lSCO1(1)) :Output(5,24,lSCO2(1)) :Output(6,24,lSCO3(1)) :Output(9,8,”BACK=ENTER”) :Pause :Goto 0 :Lbl 3 :ClrHome :Stop</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>