Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: ztrumpet on March 10, 2010, 08:52:54 pm
-
Today I made a couple of routines to encode and decode text. It stores the text into L1, 6 letters a list element. You can have messages up to 128 characters long. :)
TEXTENCD
DelVar L1ClrHome
Input "",Str1
min(128,length(Str1->L1(1
23->dim(L1
DelVar C1->B
For(A,1,L1(1))
C+1-6(C=6->C
If C=1
B+1->B
L1(B)+10^(2C-2)inString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.!?:'",sub(Str1,A,1->L1(B
End
B->dim(L1
L1
TEXTDECD
ClrHome
DelVar C1->B
For(A,1,L1(1
C+1-6(C=6->C
If C=1
Then
B+1->B
L1(Ans->D
End
.01int(D->D
int((A-1)/16
Output(1+Ans,A-16Ans,sub(" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,.!?:'",1+100fPart(D),1
End
Comments? :D
-
Nice routines! And great way to store huge amounts of text!
-
Very nice! And i'm glad your excited about Portal :)
Although i can't figure out why you are limiting the string length to 128 O.o
-
Nice, altough I am unsure if I understand the concept well. Is it to compress text too or mostly to encrypt/decrypt? The screenshot doesn't show much.
-
I think it, sort of, compresses data by taking advantage of the amount of data a REAL variable can contain. (the significand is 6 bytes, I think, which would explain the 6 letters/element ratio)
I'm sorry if this is completely wrong, but I didn't have the time to study your code.
-
It's also useful when you don't want to save the string after the program, like the character's name that the user defined. Since string variable cannot be named like list, it would be very useful to convert the string to the list, and archive the list and delete the string.
-
I think it, sort of, compresses data by taking advantage of the amount of data a REAL variable can contain. (the significand is 6 bytes, I think, which would explain the 6 letters/element ratio)
I'm sorry if this is completely wrong, but I didn't have the time to study your code.
This is completely right. Though you could store 14 digits (7 two digit numbers), fpart( will not return the right value with that many digits. :)
Although i can't figure out why you are limiting the string length to 128 O.o
I just limited it at 128 because there can only be 128 characters on the homescreen at once. :D
I'm glad you guys like it. ;D