Author Topic: Odd Text Issues  (Read 6310 times)

0 Members and 1 Guest are viewing this topic.

Offline Blue72

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +3/-0
    • View Profile
Odd Text Issues
« on: May 11, 2012, 09:58:52 pm »
So I've been puzzling over a strange issues with strings and text lately, where all my efforts to print information to the home and graph screens resulted in a bunch of gobbledy-gook (long amounts of +'s, n's, and 0's). After thinking I was coding something wrong I eventually tried doing the same thing before all of the other code, resulting in perfect text. Just wondering if anyone could shed some light on this? (I'm using TokenIDE so DeltaList = Data)

Code: [Select]
.MATRIX

Fix 5

//Initial try, works fine
Text(10,10,"FFFFF")

Repeat getKey(15)
DispGraph
End

DeltaList(0->GDB1

For(Y,0,7)
For(X,0,7)
1->{Y*8+X+GDB1}
End
End

"!"->Str1

For(P,0,15)
({4*P+GDB1}*8)+({4*P+1+GDB1}*4)+({4*P+2+GDB1}*2)+{4*P+3+GDB1}->N
"F"->{Str1+P}
End

//Second try, plus trying to figure out if I used the string right
Text(10,10,"FFFFF")
Text(10,20,Str1)

Repeat getKey(15)
DispGraph
End

Fix 4

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Odd Text Issues
« Reply #1 on: May 11, 2012, 11:14:46 pm »
Code: [Select]
DeltaList(0->GDB1

For(Y,0,7)
For(X,0,7)
1->{Y*8+X+GDB1}
End
End

It looks like you define a single byte of data for GDB1 when you use the Data(0) command, but then you write to 64 bytes of data when you are in the For() loop.  This is likely corrupting several parts of your program, including the Text you are wanting to display.

Offline Blue72

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +3/-0
    • View Profile
Re: Odd Text Issues
« Reply #2 on: May 11, 2012, 11:23:17 pm »
Any way to initialize all 64 bytes without listing them individually using Data( ?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Odd Text Issues
« Reply #3 on: May 11, 2012, 11:31:10 pm »
You can use the Zeros(#) command, which creates # empty bytes of data.  Also, "F"->{Address} doesn't work, as "F" returns the *address* of a string, not the string itself.  What you probably want is 'F'->{Address}, as 'F' returns the byte that represents the referenced character.

Offline Blue72

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +3/-0
    • View Profile
Re: Odd Text Issues
« Reply #4 on: May 12, 2012, 09:53:44 am »
I can't find any mention of a Zeros( command, so for now I'm just sticking with Data(, but correctly initializing does seem to have fixed the problem.

On another note, is there any good way to convert a number to a character? Like 1 to '1'?

EDIT:

Also, I seem to be having a weird issue where text I print before or after printing a string prints both at the given coordinates and at the end of the string. (Picture attached)

Code: [Select]
Text(2,20,Str1)
Text(2,40,"HELLO!")
« Last Edit: May 12, 2012, 10:08:01 am by Blue72 »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Odd Text Issues
« Reply #5 on: May 12, 2012, 12:32:24 pm »
It looks like you have the same issue initializing the Str1 variable?  Maybe it would help if I knew what it is you are trying to do?  And ah, I see the name of the command has been changed from Zeros() to Buff(), check it out in the commands list.

Offline Blue72

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +3/-0
    • View Profile
Re: Odd Text Issues
« Reply #6 on: May 12, 2012, 04:55:53 pm »
I ended up using Data( for it, like this:

Code: [Select]
DeltaList('0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'->Str1
Is that the wrong way to manage strings? I'm still a little confused over whether strings are actually handled any differently than raw data in Axe.

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Odd Text Issues
« Reply #7 on: May 12, 2012, 05:22:19 pm »
Everything in Axe is just raw data. :) You could draw a list of numbers as a sprite, you could read a string as a list of numbers, you could print sprite data as a string. None of those would have any meaningful output, but I'm just trying to get the idea across that, to Axe, data is just data.

One implication of this is that the Buff(#) command, which is probably det(#) in an environment like TokenIDE without the custom Axe tokens, can be used to allocate data for any purpose. For GDB1, it looks like you want it to hold 64 bytes of data. So you would initialize it like this:

det(64)→GDB1

To initialize a string that holds 16 characters, however, you need to allocate an extra 17th byte. This is because strings need a terminating null character to mark the end of the string. This is why you saw the behavior of printing Str1 resulting in both the 16 numbers and "HELLO!" because Str1 didn't have a terminating null character, so the print method printed the next string in memory as well. Defining a string like "STRING" automatically adds the terminating null character, which is why the printing stops after "HELLO!". Anyways, to initialize a string that holds 16 characters, you would do this:

det(17)→Str1


Hopefully this will help with the issues you've been experiencing!
« Last Edit: May 13, 2012, 12:42:20 am by Runer112 »

Offline Blue72

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +3/-0
    • View Profile
Re: Odd Text Issues
« Reply #8 on: May 12, 2012, 05:27:17 pm »
Thanks, knowing that really helps, and nice explanation too! I would give both of you positive post ratings, but either I don't know how or it won't let me because I have too few posts.

Offline Hayleia

  • Programming Absol
  • Coder Of Tomorrow
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3367
  • Rating: +393/-7
    • View Profile
Re: Odd Text Issues
« Reply #9 on: May 13, 2012, 01:32:12 am »
Thanks, knowing that really helps, and nice explanation too! I would give both of you positive post ratings, but either I don't know how or it won't let me because I have too few posts.
Click on the thumb up () next to the "quote" () button ;)
I own: 83+ ; 84+SE ; 76.fr ; CX CAS ; Prizm ; 84+CSE
Sorry if I answer with something that seems unrelated, English is not my primary language and I might not have understood well. Sorry if I make English mistakes too.

click here to know where you got your last +1s

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Odd Text Issues
« Reply #10 on: May 13, 2012, 02:32:00 am »
Thanks, knowing that really helps, and nice explanation too! I would give both of you positive post ratings, but either I don't know how or it won't let me because I have too few posts.
Yeah, you can't vote until you have 20 posts.  Only one away :P
Vy'o'us pleorsdti thl'e gjaemue

Offline Blue72

  • LV2 Member (Next: 40)
  • **
  • Posts: 20
  • Rating: +3/-0
    • View Profile
Re: Odd Text Issues
« Reply #11 on: May 13, 2012, 06:01:22 pm »
Yeah, you can't vote until you have 20 posts.  Only one away :P

Heh, this reply is definitely not for the sole purpose of attaining 20 posts...