Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: trevmeister66 on February 01, 2009, 05:03:11 pm
-
Well it's been a long time since I've programmed on the calc, so I'm a little rusty. I was just wondering if someone could help me optimize this code for speed:
ClrHome
"________->Str2 //8 Spaces in Str2
"_ABCDEFGHIJKLMNOPQRSTUVWXYZ->Str1
Ouput(1,1,"Whats your name?
Output(3,1,"NAME: "+Str2
7->X
8->dim(L1
For(Y,1,8
1->L1(Y
End
Repeat K=105
Output(2,X,"^ //up arrow
Output(4,X,"v //down arrow
getKey->K
//Moves arrows left or right
If K=24 or K=26
Then
Output(2,X,"_ //_ = Blank Space
Output(4,X,"_ //_ = Blank Space
X+(K=26)-(K=24
Ans+8(Ans=6)-8(Ans=15->X
End
If K=25 or K=34
Then
L1(X-6
Ans+(K=25)-(K=34
Ans+27(Ans=0)-27(Ans=28->Z
If X=7
Then
sub(Str1,Z,1)+sub(Str2,2,7
End
If X>7 and X<14
Then
sub(Str2,1,X-7)+sub(Str1,Z,1)+sub(Str2,X-5,14-X
End
If X=14
Then
sub(Str2,1,7)+sub(Str1,Z,1
End
Ans->Str2
Z->L1(X-6
Output(3,7,Str2
End
End
//Delete all variables
If you need more information about what this program does, just ask.
-
What does this program accomplish, I have better luck sometimes just re-writing it.
-
It lets the person create a 8-max letter name. They can move left or right and change the letter at that position. Every time you change a letter (by pressing up or down) it recreates the String (Str2) and displays it again. I know there's easier and faster ways to do it, but I also want it to look good instead of just entering it like normal.
-
Minor problem.
Look below... it shows it. (only hitting the arrows... the error happens on pressing up/down on the 2nd space)
This is just a direct copy of your code above.
I was testing it before I play with the optimizing... and that happened.
Can't find the issue... (maybe just too tired...)
-
Heh I know why. In the code that say
If X>8 and X<14
should be If X>7 and X<14
Heh I have it right in my program.
-
nice, kinda like Illusiat 12 naming routine (also used in Illusiat 2004)
-
nice, kinda like Illusiat 12 naming routine (also used in Illusiat 2004)
O snap. Do you think you have the code for that lying around anywhere? I'd like to take a look at it and see what differences we have and see what I can improve on.
-
Well, I doubt it is a good example. Back in the days (2002-2003) I was still using lbls/gotos inside loops, and some parhentesis were closed and " not omitted at the end of strings, just to give you an idea. If I have time to dig up the code I will post it though, but it's horrible. I would most likely do signifiantly better today.
-
Heh yeah I understand, but it never hurts to look at it even just to see how it works (even if it is unoptimized). but if you don't have it right now it's all good.
-
I made a small one, hope it works for what you want:
(http://group.revsoft.org/_theta_theta_Z.gif)
[Download 8xp] (http://group.revsoft.org/_theta__theta_Z.8xp)
:ClrHome:1→A:"ABCDEFGHIJKLMNOPQRSTUVWXYZ →Str0:"-→Str1:8→dim(L1:Fill 1,L1
:Output(1,1,"WHATS YOUR NAME?
:Output(4,1,"NAME:
:Repeat θ=21
:L[size=0]1[/size](A→B
:Repeat θ=21 or θ=26 or θ=24
:A+6
:Output(3,Ans,"
:Output(5,Ans,"
:Output(4,Ans,sub(Str0,B,1
:getKey→θ
:B+(Ans=34)-(Ans=25
:Ans-27((Ans=28)-not(Ans→B
:End
:sub(Str0,Ans,1
:If θ=24:Then:"
:Output(4,A+6,Ans:End
:sub(Str1,1,A)+Ans→Str1
:inString(Str0,sub(Ans,A+1,1→L[size=0]1[/size](A
:A+6
:Output(3,Ans,"
:Output(5,Ans,"
:A+(θ=26 and A≠8)-(θ=24 and A≠1→A
:End
:sub(Str1,2,Ans→Str1
-
Thanks! That's a lot better.
-
I assume these are the characters added in OS 1.15 or higher? This looks nice actually
-
I believe so kevin, you can get them in tifreaks font pack on ticalc. I actually now see a few optimizations in my own code..ew
-
moved to calculator help and support