Author Topic: HBJ needs some string help.  (Read 1583 times)

0 Members and 1 Guest are viewing this topic.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
HBJ needs some string help.
« 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?
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: HBJ needs some string help.
« Reply #1 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.
« Last Edit: January 10, 2012, 06:58:34 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: HBJ needs some string help.
« Reply #2 on: January 10, 2012, 06:59:15 pm »
Thanks :D
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: HBJ needs some string help.
« Reply #3 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
« Last Edit: January 10, 2012, 07:07:55 pm by Runer112 »

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: HBJ needs some string help.
« Reply #4 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.
« Last Edit: January 10, 2012, 07:23:22 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: HBJ needs some string help.
« Reply #5 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.
« Last Edit: January 10, 2012, 07:25:56 pm by Runer112 »

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: HBJ needs some string help.
« Reply #6 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. :)
« Last Edit: January 10, 2012, 07:27:00 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!