2
\$\begingroup\$

Tested on my TI-84 Plus CE.

Variables:

  • F: Stores the file listing's ID
  • N: Stores the current file's ID
  • I, J, L: Temporary variables
  • Str1: Used for input and output
  • Str2, Str3: Temporary variables
  • Str0: Used for storing the actual data
  • ⌊DATA: Stores the start of the files

The DATA- programs are for storing files by ID#, the FILES- programs are used for storing files by name.

DATAADD (creates a new file, returns the file's ID)

augment(⌊DATA,{⌊DATA(dim(⌊DATA))})→⌊DATA
dim(⌊DATA)-1→N

DATAGET (gets the contents of the current file)

If ⌊DATA(N+1)-⌊DATA(N)
Then
sub(Str0,⌊DATA(N)+1,⌊DATA(N+1)-⌊DATA(N))→Str1
Else
" "→Str1
End
Str1

DATAINI (initializes/resets the files)

" "→Str0
{1}→⌊DATA

DATASET (sets the contents of a file)

length(Str1)-⌊DATA(N+1)+⌊DATA(N)→L
If length(Str0)-⌊DATA(N+1)>0
Then
sub(Str0,1,⌊DATA(N))+Str1+sub(Str0,⌊DATA(N+1),length(Str0)-⌊DATA(N+1))→Str0
Else
sub(Str0,1,⌊DATA(N))+Str1→Str0
End
For(I,N+1,dim(⌊DATA))
⌊DATA(I)+L→⌊DATA(I)
End

DATATEST (test program for the DATA- programs)

prgmDATAINI
prgmDATAADD
prgmDATAGET
Disp Str1
"ABC"→Str1
prgmDATASET
prgmDATAGET
Disp Str1
prgmDATAADD
prgmDATAGET
Disp Str1
1→N
prgmDATAGET
Disp Str1
2→N
"DEF"→Str1
prgmDATASET
prgmDATAGET
Disp Str1
1→N
prgmDATAGET
Disp Str1
"12"→Str1
prgmDATASET
prgmDATAGET
Disp Str1

FILES (semi-GUI file manager interface)

Lbl L
Menu("Choose an action","List files",LI,"Create file",CR,"Open file",OP,"View file",VI,"Edit file",ED,"View home screen",VH,"Advanced features...",AD,"Exit",E)
Lbl AD
Menu("Advanced features","Initialize/reset files",RF,"Initialize/reset all data",RD,"View current file ID",ID,"Back",L)
Lbl LI
prgmFILESLST
Pause Str1
Goto L
Lbl CR
Input "FILENAME: ",Str1
prgmFILESADD
Goto L
Lbl OP
Input "FILENAME: ",Str1
prgmFILESID
Goto L
Lbl VI
prgmDATAGET
Pause Str1
Goto L
Lbl ED
Input "NEW CONTENTS: ",Str1
prgmDATASET
Goto L
Lbl VH
Pause ""
Goto L
Lbl RF
prgmFILESINI
Goto L
Lbl RD
prgmDATAINI
Goto L
Lbl ID
Disp N
Goto L
Lbl E

FILESADD (creates a new file)

Str1→Str2
prgmDATAADD
N→I
F→N
prgmDATAGET
Str1+" "+Str2+" "+toString(I)→Str1
prgmDATASET

FILESID (gets the file's ID)

Str1→Str2
F→N
prgmDATAGET
Str1→Str3
3→I
While I and Str1≠Str2
Str3→Str1
I→J
inString(Str1," ",I)+1→I
If I
Then
sub(Str1,J,I-J)→Str1
Else
sub(Str1,J,length(Str1)-J)→Str1
End
End
inString(Str3," ",I)+1→I
inString(Str3," ",I)→J
If J
Then
sub(Str3,I,J-I)→Str1
Else
sub(Str3,I,length(Str3)-I+1)→Str1
End
expr(Str1)→N

FILESINI (initializes the file index)

prgmDATAADD
N→F

FILESLST (lists the files' names, space separated)

F→N
prgmDATAGET
" "→Str2
2→I
While I
inString(Str1," ",I+1)→J
If not(J)
Goto E
Str2+sub(Str1,I,J-I)→Str2
inString(Str1," ",J+1)→I
End
Lbl E
If length(Str2)<3
Then
""→Str1
Else
sub(Str2,3,length(Str2)-2)→Str1
End

FILESTST (test program for the FILE- programs)

prgmFILESINI
prgmFILESLST
Disp Str1
"ABC"→Str1
prgmFILESADD
prgmFILESLST
Disp Str1
"123"→Str1
prgmFILESADD
prgmFILESLST
Disp Str1
\$\endgroup\$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.