Movement Code:

`min(16,max(1,B+sum(ΔList(K={24,26→B`

This is probably one of the most important pieces of code ever in TI-BASIC. xP If you don't understand it, don't worry. Just know that when you press Left, it subtracts 1 from B, and when you press Right, it adds 1 to B. The min() and max() set the boundaries, which in the above case, is set so that the max is 16, and the minimum is 1. Notice that it APPEARS flipped in the equation above, but I assure you, it's correct.

Since I'm assuming you'll want for it to loop when you reach the last formula though, we can scrap the min(), max() equations and instead replace it with the following line.

```
B+sum(ΔList(K={24,26→B
B+6(B=-1)-6(B=6→B
```

The following is just piecing together lirt's awesome response with some extra optimizations and the code above. The major optimization though was removing the Menu(, and instead, skips straight to the 1st equation (Quadratic). It's MUCH more efficient, and much less complications with spaghetti programming. xP

```
Delvar ADelvarBDelvarK
Repeat K=45
ClrDraw
If not(B
RecallPic 1
If B=1
RecallPic 2
If B=2
RecallPic 3
If B=3
RecallPic 4
If B=4
RecallPic 5
If B=5
RecallPic 6
Text(54,58,sub("QUADRATICDISTANCE MIDPOINT LINEAR SIN... ",1+9B,9
Repeat max(K={24,26,45
getKey→K
End
B+sum(ΔList(K={24,26→B
B+6(B=-1)-6(B=6→B
End
"
```

**COMMENTED:**

```
Delvar ADelvarBDelvarK // Deletes and prepares all of your variables for use.
Repeat K=45 // Repeat until the CLEAR button is pressed.
ClrDraw // Clears the graph screen for the picture.
If not(B // The movement code determines the picture to display.
RecallPic 1
If B=1
RecallPic 2
If B=2
RecallPic 3
If B=3
RecallPic 4
If B=4
RecallPic 5
If B=5
RecallPic 6
Text(54,58,sub("QUADRATICDISTANCE MIDPOINT LINEAR SIN... ",1+9B,9 // Displays the formula at the bottom-right hand side of the screen. Further explanation can be given, but DO NOT forget the spaces. Those are intentional.
Repeat max(K={24,26,45 // Repeat until the left, right, or CLEAR button is pressed.
getKey→K
End
B+sum(ΔList(K={24,26→B // Adds 1 if right is pressed, or subtracts 1 if left is pressed.
B+6(B=-1)-5(B=6→B // If B=6, change it to 0, and if B=-1, change it to 5. This loops the screens.
End
"
```