Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: ACagliano on September 13, 2010, 11:21:57 am

Title: Adding Strings
Post by: ACagliano on September 13, 2010, 11:21:57 am
Lets say I have data in an appvar that looks like this:

AAA,AA,A,F

and I have a string Str0ZZ that looks like this: "prgm"

and I want to move through the appvar between commas, first from AAA to AA then A then F and each time I do that I want to annex the result to Str0ZZ.

So "prgm" becomes "prgmAAA", a name string pointing to program AAA

How do I do that in Axe?
Title: Re: Adding Strings
Post by: LordConiupiter on September 13, 2010, 03:51:52 pm
perhaps you should seperate the data in the AppVar with zero's? then you could use the length( command to see how long the nam is, and then add that to a pointer to the current program-name. here is some code which should do it:
Code: [Select]
.READPRGS

GetCalc("apvrDATA")->D->P             .get the pointer to the appvar DATA
"prgm"->Str0ZZ                        .initialize Str0ZZ

While P<{D-2}rr-9                     .check for reaching the end of the AppVar
length(P)->L                          .store the length of the string at P to L, because it will be used more than once
Copy(P,Str0ZZ,L)                      .annex data at current position to Str0ZZ
P+L+1->P                              .add the length of the string at P to P to move P to the start of the next string
.Code to do whatever you want with the program...
End


this code is not tested, use at your own risk :P

I don't know wheter Str0ZZ should be Str09 or not, because I thought only Str00 till Str99 were supported, but I'm not sure about that.
Title: Re: Adding Strings
Post by: ztrumpet on September 13, 2010, 03:59:11 pm
.READPRGS

GetCalc("apvrDATA")->D->P             .get the pointer to the appvar DATA
"prgm"->Str0ZZ                        .initialize Str0ZZ
det(8 )                   .You want this here so you don't overwrite something important if there's something important right after the program in memory. :)

While P<{D-2}rr-12                    .check for reaching the end of the AppVar
length(P)->L                          .store the length of the string at P to L, because it will be used more than once
Copy(P,Str0ZZ,L)                      .annex data at current position to Str0ZZ
P+L+1->P                              .add the length of the string at P to P to move P to the start of the next string
.Code to do whatever you want with the program...
End

I don't know wheter Str0ZZ should be Str09 or not, because I thought only Str00 till Str99 were supported, but I'm not sure about that.
It's supported.  Axe supports names up to three chars now. :)
Title: Re: Adding Strings
Post by: LordConiupiter on September 13, 2010, 04:14:14 pm
.READPRGS

GetCalc("apvrDATA")->D->P             .get the pointer to the appvar DATA
"prgm"->Str0ZZ                        .initialize Str0ZZ
det(8 )                   .You want this here so you don't overwrite something important if there's something important right after the program in memory. :)

While P<{D-2}rr-12                    .check for reaching the end of the AppVar
length(P)->L                          .store the length of the string at P to L, because it will be used more than once
Copy(P,Str0ZZ,L)                      .annex data at current position to Str0ZZ
P+L+1->P                              .add the length of the string at P to P to move P to the start of the next string
.Code to do whatever you want with the program...
End
ouch! forgot about the Zeros( 8 ) or det( 8 ) part :P
I don't know wheter Str0ZZ should be Str09 or not, because I thought only Str00 till Str99 were supported, but I'm not sure about that.
It's supported.  Axe supports names up to three chars now. :)
nice to know! haven't heard/seen it anywhere, but that's my bad ;)
the -12 should be -9, but that I've already changed.

EDIT: lol! i noticed your space between the 8 and the ), but didn't see why, but now I see 8) :P
Title: Re: Adding Strings
Post by: Builderboy on September 13, 2010, 05:17:52 pm
The three character names are a lifesaver when naming subroutines ^^ Now they are semi intelligible! :D
Title: Re: Adding Strings
Post by: meishe91 on September 13, 2010, 05:26:48 pm
.READPRGS

GetCalc("apvrDATA")->D->P             .get the pointer to the appvar DATA
"prgm"->Str0ZZ                        .initialize Str0ZZ
det(8 )                   .You want this here so you don't overwrite something important if there's something important right after the program in memory. :)

While P<{D-2}rr-12                    .check for reaching the end of the AppVar
length(P)->L                          .store the length of the string at P to L, because it will be used more than once
Copy(P,Str0ZZ,L)                      .annex data at current position to Str0ZZ
P+L+1->P                              .add the length of the string at P to P to move P to the start of the next string
.Code to do whatever you want with the program...
End
ouch! forgot about the Zeros( 8 ) or det( 8 ) part :P
I don't know wheter Str0ZZ should be Str09 or not, because I thought only Str00 till Str99 were supported, but I'm not sure about that.
It's supported.  Axe supports names up to three chars now. :)
nice to know! haven't heard/seen it anywhere, but that's my bad ;)
the -12 should be -9, but that I've already changed.

EDIT: lol! i noticed your space between the 8 and the ), but didn't see why, but now I see 8) :P

Wait, why?
Title: Re: Adding Strings
Post by: Builderboy on September 13, 2010, 05:30:35 pm
try it and see what happens :D
Title: Re: Adding Strings
Post by: DJ Omnimaga on September 13, 2010, 05:35:23 pm
.READPRGS

GetCalc("apvrDATA")->D->P             .get the pointer to the appvar DATA
"prgm"->Str0ZZ                        .initialize Str0ZZ
det(8 )                   .You want this here so you don't overwrite something important if there's something important right after the program in memory. :)

While P<{D-2}rr-12                    .check for reaching the end of the AppVar
length(P)->L                          .store the length of the string at P to L, because it will be used more than once
Copy(P,Str0ZZ,L)                      .annex data at current position to Str0ZZ
P+L+1->P                              .add the length of the string at P to P to move P to the start of the next string
.Code to do whatever you want with the program...
End
ouch! forgot about the Zeros( 8 ) or det( 8 ) part :P
I don't know wheter Str0ZZ should be Str09 or not, because I thought only Str00 till Str99 were supported, but I'm not sure about that.
It's supported.  Axe supports names up to three chars now. :)
nice to know! haven't heard/seen it anywhere, but that's my bad ;)
the -12 should be -9, but that I've already changed.

EDIT: lol! i noticed your space between the 8 and the ), but didn't see why, but now I see 8) :P

Wait, why?
8 and ) stuck together turns into the 8) emoticon. That's unless you disable smileys on your post (or use [ CODE ]), though.
Title: Re: Adding Strings
Post by: meishe91 on September 13, 2010, 05:37:15 pm
Oh, I knew that :P I thought that was part of the actual code lol. Like in Axe you actually had to put that space there :P
Title: Re: Adding Strings
Post by: ACagliano on September 13, 2010, 06:22:05 pm
thanks all.
Title: Re: Adding Strings
Post by: LordConiupiter on September 14, 2010, 02:28:54 am
you're welcome!
Title: Re: Adding Strings
Post by: ACagliano on September 14, 2010, 09:18:34 am
perhaps you should seperate the data in the AppVar with zero's? then you could use the length( command to see how long the nam is, and then add that to a pointer to the current program-name. here is some code which should do it:
Code: [Select]
.READPRGS

GetCalc("apvrDATA")->D->P             .get the pointer to the appvar DATA
"prgm"->Str0ZZ                        .initialize Str0ZZ

While P<{D-2}rr-9                     .check for reaching the end of the AppVar
length(P)->L                          .store the length of the string at P to L, because it will be used more than once
Copy(P,Str0ZZ,L)                      .annex data at current position to Str0ZZ
P+L+1->P                              .add the length of the string at P to P to move P to the start of the next string
.Code to do whatever you want with the program...
End


this code is not tested, use at your own risk :P

I don't know wheter Str0ZZ should be Str09 or not, because I thought only Str00 till Str99 were supported, but I'm not sure about that.


Hey, LordConiupter. Actually the creation of the appvar is being handled by KermM in inline asm. The format of the appvar will length-prepended. For example:


Edit:

I spoke to Kerm Martian. Assume the appvar holds only the name of the program AAA. The data will appear as:

03414141

Where 03 tells you that you are taking the next 3 bytes and 414141 is the three byte representation for AAA.

And so on for every program in the appvar.