Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Blue72 on May 11, 2012, 09:58:52 pm

Title: Odd Text Issues
Post by: Blue72 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
Title: Re: Odd Text Issues
Post by: Builderboy 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.
Title: Re: Odd Text Issues
Post by: Blue72 on May 11, 2012, 11:23:17 pm
Any way to initialize all 64 bytes without listing them individually using Data( ?
Title: Re: Odd Text Issues
Post by: Builderboy 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.
Title: Re: Odd Text Issues
Post by: Blue72 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!")
Title: Re: Odd Text Issues
Post by: Builderboy 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.
Title: Re: Odd Text Issues
Post by: Blue72 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.
Title: Re: Odd Text Issues
Post by: Runer112 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!
Title: Re: Odd Text Issues
Post by: Blue72 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.
Title: Re: Odd Text Issues
Post by: Hayleia 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 ((http://omnimaga.org/Themes/default/images/gpbp_arrow_up.gif)) next to the "quote" ((http://omnimaga.org/Themes/omnimaga4/images/english/quote.gif)) button ;)
Title: Re: Odd Text Issues
Post by: Darl181 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
Title: Re: Odd Text Issues
Post by: Blue72 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...