Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Deep Toaster on October 31, 2011, 07:30:51 pm

Title: Encoding eight characters as a single number
Post by: Deep Toaster on October 31, 2011, 07:30:51 pm
Just wanted to share a little routine I made to store eight bytes of uppercase text as a single real variable (for example for high-score player names).
Operation
Input
Output
Code
Encoding
Str0
Ans
(http://clrhome.org/homer/%3A0%D6%3AFor%28I%2C1%2C8%D6%3A30Ans%2BinString%28%22ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%20%3A%3F%22%2Csub%28Str0%2CI%2C1%D6%3AEnd.gif)
Decoding
J
Str0
(http://clrhome.org/homer/%3A%22%20%1CStr0%D6%3AJ%D6%3AFor%28I%2C1%2C8%D6%3AAns/30%1CJ%D6%3Asub%28%22ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%20%3A%3F%22%2Cround%2830fPart%28Ans%29%2C0%29%2C1%29%2BStr0%1CStr0%D6%3AiPart%28J%D6%3AEnd.gif)
Title: Re: Encoding eight characters as a single number
Post by: parserp on October 31, 2011, 07:32:03 pm
Exactly what I need to finish my BASIC game!!! +1
Title: Re: Encoding eight characters as a single number
Post by: Deep Toaster on October 31, 2011, 07:33:40 pm
GIF of it in action, with the actual program:
Title: Re: Encoding eight characters as a single number
Post by: Hot_Dog on October 31, 2011, 07:50:03 pm
This would be awesome for lists, because people are less likely to delete lists than Real Variables
Title: Re: Encoding eight characters as a single number
Post by: parserp on October 31, 2011, 07:51:45 pm
and you can create lists, but you can't create strings!
it all works out!!! ;D
Title: Re: Encoding eight characters as a single number
Post by: Deep Toaster on October 31, 2011, 07:53:47 pm
This would be awesome for lists, because people are less likely to delete lists than Real Variables
Yep, that's what I'm doing. A list of just ten elements (ninety bytes) is enough for five names and five high scores :D
Title: Re: Encoding eight characters as a single number
Post by: GB on December 19, 2011, 04:54:58 pm
Have you tried storing strings directly into lists?
Title: Re: Encoding eight characters as a single number
Post by: Deep Toaster on December 19, 2011, 04:56:04 pm
Why do that when you can store the same string in one-eighth the memory? :D