Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Raylin on September 15, 2010, 09:06:46 pm

Title: The most efficient way to store and recall lots of text
Post by: Raylin on September 15, 2010, 09:06:46 pm
Yeah... what the title says.
Title: Re: The most efficient way to store and recall lots of text
Post by: LordConiupiter on September 15, 2010, 09:11:29 pm
I mostly use the following system to store any kind of data with variable lengths to an AppVar:
first byte: number of datablocks in the AppVar
foreach datablock: one word/ two bytes: offset, relative to the start of the AppVar
foreach datablock: variable amount of bytes: the data at the position pointed to by the offset word.

but i think the most efficient way to do it when you have left over enough room in your program, to store it in your program.
Title: Re: The most efficient way to store and recall lots of text
Post by: Raylin on September 15, 2010, 09:18:05 pm
I'm trying to save all of the text in my game to one string.
Title: Re: The most efficient way to store and recall lots of text
Post by: Quigibo on September 15, 2010, 09:20:48 pm
If you mean memory efficient, you might want to try some kind of compression by using a reduced character set.  26 uppercase, 26 lowercase, 10 numbers, a space, and a 'special character' is 64 possibilities (6 bits) which means you can store 4 characters in only 3 bytes.  'special character' (which is the binary combination 000000) would look at the next character which could be one of 64 special characters like a period, exclamation mark, parenthesis, question mark, apostrophe, and most importantly the end-of-line character.  That makes all your text data about 20% smaller.

Another strategy is to chose 255 of the most used words and have a list of these "common words" to form a sentence with the unused combination representing that you will spell out the word instead.  That can lead to reduction of over 50% for large text files.

Either way, you'll have to make a decoder/encoder to actually use them in your programs.
Title: Re: The most efficient way to store and recall lots of text
Post by: LordConiupiter on September 15, 2010, 09:22:53 pm
well, you could do it the way KermM does it, like described here: http://ourl.ca/7036/117479.
i prefer the way I would do it, cuz else I wouldn't have invented it :)
Title: Re: The most efficient way to store and recall lots of text
Post by: meishe91 on September 15, 2010, 09:24:18 pm
Hmmm, well you could store it all in one string then have a certain token that is at the beginning and end of a phrase then when a phrase is triggered it stores the number of the beginning character to whatever then use inString( to find the second one and then use sub( output the result. I don't know if that helps or even makes a lot of sense.

Oh, this is Axe. My bad :P Didn't even think to check.