Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Broseph Radson on May 16, 2011, 11:52:04 am
-
0.5.1
Im trying to store program names to a program in the following format:
4BOB[00] ;length of name, name, terminator
But when i try to read from it, the first character (number) is always 0, and if i try to copy the progname to L1, it either crashes when i execute it, or Axe crashes on compile.
Ok so i have a program called ADAT which holds the data, and the main program looks like this:
.ADATRD
GetCalc("prgmADAT")->P ;get pointer to program
Copy("4ABC"[00],P,5) ;Copy first progname to ADAT
Copy("5DEFG"[00],P+4,6) ;Copy next progname to ADAT
Copy(P,A,1) ;Get specified length of first progname
Disp A>Dec ;Display the length (this is always 0 for some reason?)
Copy(P+1,L1,A) ;Copy name+terminator to L1 (this part crashes the calc on compile?)
Disp i
Disp L1 ;Hopefully display the name of the program
???
It also crashes on compile if I replace A in Copy(P+1, L1,A) with 4.
-
You are not creating the program. To create a prog, use GetCalc("prgmBLABLABB",size)-> pointer.
-
Forgot to mention i made the prog separate. And after throwing my phone and openly yelling at it in class, my internet seems to be working again.
-
lol. I have to think 'bout this problem.
-
Ill update my axe this thursday
-
The problem resides in this line:
Copy(P,A,1) ;Get specified length of first progname
It seems that what you want to do is read {P} and put it into A. However, what this is actually doing is reading {P} and putting it into {A}. The reason your debug text always displays 0 is because A retains whatever value it had before your program started, which was probably 0. At the next Copy(), you may think the copy would at least do nothing because A equals 0, but this is not the case. Because of how copying works, it will copy a whopping 65536 bytes from P+1 to L1, horribly corrupting the contents of RAM and causing a certain crash. You want to use this instead:
{P}→A
Also, although this isn't causing any fatal errors, the P+4 in line 4 should be P+5.
-
The solution came from the soluted person who solves all solvable solutions. Idk what that means. Runer, nice explaination.
-
Changing P+4 to P+5 seemed to stop the crashing. Its returning BOB properly now, but {P}->A returns 52 instead of 4.
-
Oh right, I forgot. Instead of defining program names like "4ABC"[00], you should define them like [04]"ABC"[00]. You want the first byte to be 4, not the ASCII value for 4.
-
Ah! IDK why i didnt think of that :banghead:
Thanks :)
-
I always had troubles with data myself, I always kept inverting the two different getcalc syntaxes or misordering the code I need, as I never figured out how it worked. This was pretty much what made me drop out of Axe programming a year ago :(