Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: cooliojazz on April 14, 2011, 11:32:41 am
-
I was writing a program, and I decided it would be easier to write with subroutines, so I came up with
.Sub call to 0
1→N
While N
If Ans:Goto 0
0→N
End
Lbl 0
.Sub Code
0:End
But the sub call being still like 3 lines when it's "compressed" onto one line is almost as long as the code I wanted to put in the subroutine. Can anyone think of a smaller way to create a subroutine call in basic?
-
Hm, that's an interesting way to do it. Very nice. I don't think you'll get it much smaller though.
-
You don't think so? :(
-
Wow thats cool
EDIT:
For(A,1,4,3)
sub("ABCDEF",A,3)->Str1
1->N
While N
If Ans:Goto 0
0->N
End
End
Return
Lbl 0
Disp Str1
0:End
I didnt know you could do that ;D
-
Wat? O.o
-
It stores the first half of "ABCDEF" to Str1 then calls the subroutine to display it, then it stores the second half of "ABCDEF" to Str1 and does the same thing.
Produces the output:
ABC
DEF
Done
-
I don't think he was talking about yours. I think there was a post between yours and his that got deleted, if I remember correctly, that was kind of odd.
-
Oh heh
-
Good idea, however I believe due to a bug in the way TI-BASIC functions, that will cause a huge memory leak...
-
Oh... :(
-
Broseph Radsons code will not produce a memory leak, he correctly matches both sets of Ends to their corresponding starting loops, and if he ever exits a loop with a Goto, he uses a carefully placed End to make sure the code returns to the same scope of the program, preventing the memory leak from growing. In essence, he actually exploits the memory leak you talk about, and accounts for it such that it doesn't build up :)
-
Cool ;D