Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Happybobjr on January 10, 2012, 05:43:50 pm

Title: HBJ needs some string help.
Post by: Happybobjr on January 10, 2012, 05:43:50 pm
Ok, so i have 152 strings in an appvar, and each is 10 characters (1-byte) long.
Well the names in them are between 3 and 10 characters long, but i only know how to call on them if their length is uniform.
for example... "natham____" (_ = space)

Is there any more efficient ways to do this?
Title: Re: HBJ needs some string help.
Post by: Quigibo on January 10, 2012, 06:57:48 pm
Since I've seen this asked several times, I decided to add a command for it to the next version :)

But for now, you can do this using the fact that each string is zero terminated.  All you have to do is start at the pointer and then increase it until you pass N zeros to get the Nth string.
Title: Re: HBJ needs some string help.
Post by: Happybobjr on January 10, 2012, 06:59:15 pm
Thanks :D
Title: Re: HBJ needs some string help.
Post by: Runer112 on January 10, 2012, 07:04:39 pm
Why add a whole new command for it? Just make Data() not barf when you put static data inside of it, and making speedy data LUTs with anonymous entries would be a piece of cake. ;)

Data("Hello"r,"there!"r,"I"r,"am"r,"a"r,"LUT"r,"of"r,"strings."r)→Str0
Title: Re: HBJ needs some string help.
Post by: Quigibo on January 10, 2012, 07:16:26 pm
@Runer, that wasn't what I was referring to... the actual lookup table is easy enough to generate already: "Hello"[00]"World"[00]"GoodBye"[00] etc.  I was referring to a command that takes the table and an index and the returns the pointer to that string.

EDIT: Also, I just realized you were talking about something entirely different.  That type of command is difficult with Axe's limited memory because you can't determine where to put the static data until the size of the Data() command is known.
Title: Re: HBJ needs some string help.
Post by: Runer112 on January 10, 2012, 07:23:40 pm
I figured that you weren't referring to the method I was. Your method is the size-optimized method, mine is the speed-optimized method. :P Your method would take n+1 bytes of storage for each entry and lookups would run in linear time, whereas my method would take n+2 bytes of storage for each entry and lookups would run in constant time. Unfortunately, my method doesn't work because Axe won't let me put static data inside of Data(). :(

EDIT: Just read your edit, and I guess that's true. Unless there's some way to get around it by determining the Data() pointer in the first pass and the anonymous data entry pointers in the second pass, but if there was, you would know better than I.
Title: Re: HBJ needs some string help.
Post by: Quigibo on January 10, 2012, 07:26:15 pm
But you can always store the data to static pointers first and then put them in the Data() after. :)