# TI-83/84 Programming



## MistArts (Oct 6, 2008)

I have recently started programming on my TI-84 Plus borrowed for the school year. I've created a timer and a semi-working clock scrambler. I don't have a manual or anything like it so I had to figure somethings out and google some.

Right now, I have some questions and problems.

Is it possible to get rid of the "Done" after my timer is complete?

Here's my timer:

```
:ClrHome
:Disp "READY"
:Pause
:checkTmr(1)→A
:ClrHome
:Disp "RUNNING..."
:Pause
:ClrHome
:checkTmr(1)-A→B
:Disp "YOUR TIME IS:"
:Output(1,14,B
:
```

Clock Scrambler:

```
:ClrHome
:randInt(-5,6)→A
:randInt(-5,6)→B
:randInt(-5,6)→C
:randInt(-5,6)→D
:randInt(-5,6)→E
:randInt(-5,6)→F
:randInt(-5,6)→G
:randInt(-5,6)→H
:randInt(-5,6)→I
:randInt(-5,6)→J
:randInt(-5,6)→K
:randInt(-5,6)→L
:randInt(-5,6)→M
:randInt(-5,6)→N
:Output(1,1,"UUDD U=
:Output(2,6,"D=
:Output(3,1,"UUDD U=
:Output(4,6,"D=
:Output(5,1,"UUDD U=
:Output(6,6,"D=
:Output(7,1,"UUDD U=
:Output(8,6,"D=
:Output(1,10,"DUUU
:Output(2,10,"UDUU
:Output(3,10,"UUUD
:Output(4,10,"UUDU
:Output(5,10,"UUUU
:Output(6,10,"DDDD
:Output(1,8,"A
:Output(2,8,"B
:Output(3,8,"C
:Output(4,8,"D
:Output(5,8,"E
:Output(6,8,"F
:Output(7,8,"G
:Output(8,8,"H
:Output(1,15,"I
:Output(2,15,"J
:Output(3,15,"K
:Output(4,15,"L
:Output(5,15,"M
:Output(6,15,"N
:randInt(1,2)→A
:randInt(1,2)→B
:randInt(1,2)→C
:randInt(1,2)→D
:If A=1
:Then
:Output(8,11,"U
:Else
:Output(8,11,"D
:End
:If B=1
:Then
:Output(8,12,"U
:Else
:Output(8,12,"D
:End
:If C=1
:Then
:Output(8,13,"U
:Else
:Output(8,13,"D
:End
:If D=1
:Then
:Output(8,14,"U
:Else
:Output(8,14,"D
:End
:
```

I need help simplifying that.

Here's my number guesser:

```
ClrHome
:randInt(1,10)→A
:Lbl A
:Disp "ENTER 1 To 10"
:Prompt X
:ClrHome
:If A=X
:Then
:Disp "CORRECT
:Goto B
:Else
:Disp "TRY AGAIN
:Pause
:ClrHome
:Goto A
:Lbl B
:
```


----------



## d_sprink (Oct 7, 2008)

Dude, I love programming for that thing!!!

Yeah, just put an extra 

:

at the end, I think that should do it.

I need to make a scrambler for this... it would be so easy. Ok. It's been a while... I was the only kid at my school to make games


----------



## d_sprink (Oct 7, 2008)

MistArts said:


> I have recently started programming on my TI-84 Plus borrowed for the school year. I've created a timer and a semi-working clock scrambler. I don't have a manual or anything like it so I had to figure somethings out and google some.
> 
> Right now, I have some questions and problems.
> 
> ...



I only had the Ti-83 though. I'm not familiar with the checkTmr function. I did it the old fashioned way with several nested For(x,1,60) loops, then outputting each variable to each position... I hope that made sense. I'll give you the source code (if I can find it again, I'm to lazy to type it right now ) if it didn't. Good luck! I'm making a scramble program right now...


----------



## TimMc (Oct 7, 2008)

Lbl and Goto will be a lot faster than While or For loops.

Take a look at education.ti.com and download the 84 manual if you want more information on the commands it has to offer.

An easy way to make a scrambler would be to take two strings and use some random numbers to determine which character to use in each string:
"FBLRUD->str1
"'2->str2

Tim.


----------



## MistArts (Oct 7, 2008)

I found this timer today, but I don't understand the beginner or the end. All I know that it's looping and displaying another number while waiting for you to put the "ENTER" key.


```
Disp "READY..."
Pause
0->A
0->B
While A=0 or A=115
getKey->A
ClrHome
Disp round(B/15.4**,2)
B+1->B
End
ClrHome
Disp round(B/15.4**,2)
round(B/15.4**,2)->X
Pause
```


----------



## d_sprink (Oct 9, 2008)

*Rubik's Scramble program*

Ok, I made a cube scramble in class today because I got bored and couldn't sleep... it gives 24 'moves,' but the spacing of the lettering can be weird at times. I'm sure someone can improve on this. Its relatively long for what it accomplishes, yet still simple in design.

Oh, I'm using the symbol » to represent the "store variable" character. The arrow thing that says STO on the key.


```
:
:Lbl 1
:ClrDraw
:AxesOff
:Text(0,8,"RUBIK'S CUBE SCRAMBLE
:
:For(X,1,2)
:For(N,1,12)
:randInt(1,6)»S
:randInt(1,3)»D
:
:If S=1
:"U"»Str1
:If S=2
:"R"»Str1
:If S=3
:"L"»Str1
:If S=4
:"F"»Str1
:If S=5
:"B"»Str1
:If S=6
:"D"»Str1
:Text((24=8X),(8(N-1)+1),Str1
:
:If D=1
:""»Str2
:If D=2
:"'"»Str2
:If D=3
:"2"»Str2
:Text((24+8X),(8(N-1)+5),Str2
:
:End:End
:Pause
:Goto 1
```

Ok, obviously there is no way to end the program without breaking it, but you will see you get a new scramble every time you hit enter. And It would be easy to use the getkey function instead of pause to allow the user to quit, but I was getting lazy, and the bell was about to ring. So... My main concerns are:
Spacing - There is always enough room for a "2" between side labels, despite the existance thereof.
Randomness - I've come up with scrambles telling me to turn the L face 3 or more times in a row, etc. Any ways to fix this?

It's a start. We'll see where this goes.


----------



## ezh (Oct 12, 2008)

TimMc said:


> Lbl and Goto will be a lot faster than While or For loops.



Lbl and Goto are completely inferior to While and For loops in TI-Basic. First of all, Lbl and Goto are almost always slower. You can test this out yourself by running the following two programs and comparing the runtime:


```
:For(I,1,2000)
:End
```


```
:1→A
:Lbl A
:A+1→A
:If A<2000
:Goto A
```
For me, the second program takes more than five times longer to run.

Also, as you can see, using Goto takes up a lot more space than using For. The second segment of code uses up twice as much space as the first segment of code.

Finally, using Goto leads to memory leaks. Try running the following program:

```
:1→A
:Lbl A
:If A<2000
:Then
:Goto A
:End
```

If you run this and wait, the calculator will return an Err:Memory after some time. This is because every time the program gets to the Goto, it leaves the conditional block without reaching the End. By repeatedly opening up new conditional blocks without closing any, the program fills up the calculator's memory and causes an error in a short amount of time.

Now there may be some situations where using Lbl or Goto is acceptable. However, most of the time, branching with Goto leads to slower runtime, a larger program size, and memory errors. I'd recommend using For, While, and Repeat loops all the time, because they are much cleaner, more organized, and more flexible than Lbl and Goto.

Here is a scramble generator I wrote, using For and Repeat:

```
:int(6rand→F
:For(I,1,5
:"_→Str0 //the underscore is a space
:For(J,1,5
:Repeat not(3=D and A
:randInt(1,5→D
:End
:Ans=3→A
:round(6fPart((F+D)/6→F
:Str0
:If int(3rand
:sub("2'",randInt(1,2),1)+Ans // You can find sub( in the catalog: [2nd] [0]
:"_"+sub("URFDLB",1+F,1)+Ans→Str0 //again, underscore is space
:End
:Disp Ans
:End
```

If you're interested in learning more about TI-Basic, I recommend you visit the TI-Basic Developer wiki. It's a pretty detailed tutorial on TI-Basic and it has a lot of useful information that you _won't_ find in the manual.


----------



## joey (Oct 12, 2008)

I know this isn't really the right thread, but it doesn't really deserve a thread of its own.

```
ruby -e'def a;gets;Time.now;end;loop{p -(a-a)}'
```

Credit to TimH who gave me the idea on how to drop 2 chars.


----------

