Tuesday, September 18, 2018

TI-84 Plus CE: Storing Names in a Concentrated String

TI-84 Plus CE: Storing Names in a Concentrated String 

Introduction

The program STRNAMES allows the user to store a list of names in a single string.  There are only 10 string variables for the TI-84 Plus CE (and in fact, all the the TI-83 and TI-84 families), so if you need to store more than 10 names, a workaround is needed.

This program uses two strings:  Str1 and Str2.  Str1 is a temporary string variable used to store and edit the list of names.  Str2 is the master list of all the names. 

In order to make this work, we will need to note where in the string the names start and the length of the names.  The two lists used are L₁, the position of each name, and L₂ for the length of each name.

In this program, each name is separated by space.

You will notice that Str2 starts with a space, and the lists L₁ and L₂ have a 0.  The TI-84 Plus CE does not allow us to store empty strings or lists. 

STRNAMES The Menu

1.  Add a Name:   Add a name to the list
2.  Delete Last Name:  Deletes the last name on the list
3.  Clear/Initialize:  Clears all the variables.  I recommend you start with this option every time you work with a new list of names.  Also, if you use other programs or the list or strings for other things, run the Clear/Initialize before beginning.
4.  Review:  List all the names in order.
5.  Erase Any Name:  You can erase any name in the list (1st name, 2nd name, 3rd name, etc).
6.  Exit: Quits the Program

TI-84 Plus CE Program STRNAMES

"2018-09-18 EWS"
Lbl 0
Menu("MENU","ENTER A NAME",A,"DELETE LAST NAME",B,"CLEAR/INITIALIZE",C,"REVIEW",D,"ERASE ANY NAME",E,"EXIT",F)

Lbl A
Input "NAME: ",Str1
augment(L₁,{length(Str2)+1})→L₁
augment(L₂,{length(Str1)}→L₂
Str2+Str1+" "→Str2
Disp "ADDED",Str2,"NAMES:",dim(L₁)-1
Pause 
Goto 0

Lbl B
If dim(L₁)≠1
Then
dim(L₁)→I
L₂(I)→B
length(Str2)→C
sub(Str2,1,C-B-1)→Str2
dim(L₁)-1→dim(L₁)
dim(L₂)-1→dim(L₂)
Disp "DONE.",Str2,"NAMES:",dim(L₁)-1
Else
Disp "LIST IS EMPTY."
End
Pause 
Goto 0

Lbl C
" "→Str2
{0}→L₁
{0}→L₂
Disp "CLEARED"
Pause 
Goto 0

Lbl D
For(I,2,dim(L₁))
L₁(I)→A
L₂(I)→B
dim(L₁)→C
toString(I-1)+"/"+toString(C-1)+": "+sub(Str2,A,B)→Str1
Disp Str1
Wait 0.5
End
Pause 
Goto 0

Lbl E
Input "ENTRY NUMBER:",I
I+1→I
dim(L₁)→D
L₂(I)→E
If D=I
Then
Goto B
Else
L₁(I)→A
L₁(I+1)→B
length(Str2)→C
sub(Str2,1,A-1)+sub(Str2,B,C-B)+" "→Str2
For(K,I+1,D)
L₁(K)-E-1→L₁(K-1)
L₂(K)→L₂(K-1)
End
dim(L₁)-1→dim(L₁)
dim(L₂)-1→dim(L₂)
Disp "DONE.",Str2,"NAMES:",dim(L₁)-1
Pause 
End
Goto 0

Lbl F
Disp "END PROGRAM"

Example

Try playing with this program.

Example list:

1.  Start by initializing, choose option 3.

2.  Enter EDDIE.  Choose option 1.  Press [ 2nd ] [alpha] and type EDDIE.  Quotes are not needed (since the Input command will be stored to a string).  Str2 = " EDDIE "

3.  Enter ANN.  Choose option 1.  Str2 = " EDDIE ANN "

4.  Enter TERRY.  Choose option 1. Str2 = " EDDIE ANN TERRY "

5.  Let's remove ANN from the list.  In our example, ANN is the second name.  Choose option 5.  Enter 2.  The result, Str2 = " EDDIE TERRY "

6.  Enter MARK.  Choose option 1.   Str2 = " EDDIE TERRY MARK "

7.  Review the list of names.  Choose option 4.  The screen will show:

1/3 EDDIE
2/3 TERRY
3/3 MARK

Continue with the example however you want. 

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.