Author Topic: Adding Strings  (Read 8388 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Adding Strings
« 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?
« Last Edit: September 13, 2010, 11:22:31 am by ACagliano »

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Adding Strings
« Reply #1 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.
« Last Edit: September 13, 2010, 04:23:05 pm by LordConiupiter »
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Adding Strings
« Reply #2 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. :)
« Last Edit: September 13, 2010, 03:59:27 pm by ztrumpet »

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Adding Strings
« Reply #3 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
« Last Edit: September 13, 2010, 04:22:50 pm by LordConiupiter »
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Adding Strings
« Reply #4 on: September 13, 2010, 05:17:52 pm »
The three character names are a lifesaver when naming subroutines ^^ Now they are semi intelligible! :D

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Adding Strings
« Reply #5 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?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Adding Strings
« Reply #6 on: September 13, 2010, 05:30:35 pm »
try it and see what happens :D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Adding Strings
« Reply #7 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.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Adding Strings
« Reply #8 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
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Adding Strings
« Reply #9 on: September 13, 2010, 06:22:05 pm »
thanks all.

Offline LordConiupiter

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 339
  • Rating: +3/-0
  • Just one of the thousands of Axe-fans...
    • View Profile
Re: Adding Strings
« Reply #10 on: September 14, 2010, 02:28:54 am »
you're welcome!
everytime that I was down, you would always come around, and get my feedback on the ground. (modified part from 'Seasons in the sun')

No matter how many errors are bothering you, always try to stay rel-Axe!

The HoMM project will be resumed as soon Axe 1.0.0 will be released!
Projects:
Code: [Select]
HoMM:   [==--------]    Project 'resumed': I'm suffering overwhelming new ideas being popped up in my dreams :P
tiDE:   [----------]    Explored and understood the main part of the code: just started writing a Tokenizer.



password of the week: uvanapererubupa (Any pronunciation is the right one ;) )   :D click me, and you'll be raided :D

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Adding Strings
« Reply #11 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.
« Last Edit: September 14, 2010, 12:16:25 pm by ACagliano »