Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: Freyaday on August 19, 2011, 09:00:46 pm

Title: Help With Nymless!
Post by: Freyaday on August 19, 2011, 09:00:46 pm
This code crashes the calc. The code not working is all that's holding back Nymless.

E15->{L1}r
ClrHome
input->p
Copy(P,L1+1,length(P)+1)
ClrHome
If GetCalc(L1)->A
Disp "AN APPVAR EXISTS WITH THAT NAME"
Return
End
GetCalc("appvNYMSCAPE")->U
!If U
Disp "NO NYMLEVEL!"
Else
10->X
"appvNYMLIST"->Str1
UnArchive Str1
!If GetCalc(Str1)
GetCalc(Str1,0)->Q
Else
GetCalc(Str1)->Q
End
{Q-2}r->W
"appvNYMTEMP"->Str2
GetCalc(Str2,W)->V
Copy(Q,V,W)
Copy(P,V+W,length(P))
GetCalc(Str1,W+8)->T
Copy(V,T,{V-2}r)
DelVar Str2
GetCalc("appvNYMINE")->V
X+{U-2}r->X
If V
X+{V-2}r+2->X
End
GetCalc("appvNYMSHIM")->W
If W
X+{W-2}r+2->X
End
Copy(oX,{T-2}r-2,2)
Archive Str1
GetCalc(L1,X)->X
If B
Disp "APPVAR SUCCESSFULLY CREATED"
Else
Disp "APPVAR CREATION FAILED"
End
Copy(P,B,length(P))
{U-2}r->Y
Copy(U,B+9,Y)
0->C

It hasn't made it this far yet.
There's more code though.
Title: Re: Help With Nymless!
Post by: Darl181 on August 19, 2011, 11:29:17 pm
How far does it get before it crashes?

Also the input command is really buggy, I've put it in test programs and got crashes as well.  I think there's an input alternative somewhere, in the routines thread or something...
Title: Re: Help With Nymless!
Post by: LincolnB on August 19, 2011, 11:31:14 pm
Can you explain any more? Also, it's a pain, but it might be helpful to write your own input function. I think I have one somewhere I can dig up...
Title: Re: Help With Nymless!
Post by: Freyaday on August 19, 2011, 11:57:16 pm
I don't know how far it gets. All I know is that it doesn't get to "APPVAR SUCCESSFULLY CREATED"
Title: Re: Help With Nymless!
Post by: Runer112 on August 20, 2011, 12:16:18 am
Assuming you're experiencing this problem with Axe 1.0.0 or above, see: http://ourl.ca/4072/236963 (http://ourl.ca/4072/236963)
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 12:18:33 am
Nah, this is 0.5.3
Title: Re: Help With Nymless!
Post by: Runer112 on August 20, 2011, 12:32:16 am
In that case, this portion looks suspicious:

Code: [Select]
{Q-2}ʳ→W
"appvNYMTEMP"→Str2
GetCalc(Str2,W)→V
Copy(Q,V,W)
Copy(P,V+W,length(P))

You create an appvar pointed to by V of size W, and then copy data to V+W. This would be copying data outside of the appvar you created, overwriting other data. I'm guessing you wanted to make the appvar larger, perhaps length(P)+W bytes?


Also, this problem probably hasn't cropped up yet for you, but when making these new/temp appvars, you should really check that the creation was successful and throw an error if it wasn't.
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 12:58:29 am
I changed the line as you suggested, and it still crashed.
I wish there were code analysis tools for Axe, because I often look at my own code and wonder what the hell I was doing.
Title: Re: Help With Nymless!
Post by: Darl181 on August 20, 2011, 01:14:33 am
Maybe you could run it in wabbit, and see what its debugger says?

Also, some input routines.
http://ourl.ca/6581
http://ourl.ca/4129/170416
http://ourl.ca/4129/80803
http://ourl.ca/4129/125194
http://ourl.ca/4129/122465
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 01:17:59 am
I don't know how to use Wabbit's debugger though. I know where to find it, but I don't know how to use it.
Title: Re: Help With Nymless!
Post by: Darl181 on August 20, 2011, 01:22:58 am
Hmm.
A way that might help determine: have it display chars to the homescreen at points.  Like, just before the first part you suspect, put a
Disp 1►Dec
Pause 200

before it, and for the second part a Disp 2, etc.


btw I'm guessing there'll be someone on IRC who knows how to use the debugger :)
Title: Re: Help With Nymless!
Post by: LincolnB on August 20, 2011, 02:28:09 pm
Watch out for code sections like this:


If GetCalc(L1)->A
Disp "AN APPVAR EXISTS WITH THAT NAME"
Return
End


Because what it will do is display AN APPVAR EXISTS WITH THAT NAME really fast and then exit the program without you ever knowing. You can change that by adding this:

Code: [Select]

If GetCalc(L1)->A
Disp "AN APPVAR EXISTS WITH THAT NAME"
Repeat getkey(15)
End
Return
End


So it waits until they press clear, then returns.
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 04:22:54 pm
Oh. Right./me facepalms
Title: Re: Help With Nymless!
Post by: LincolnB on August 20, 2011, 05:36:01 pm
Was that the problem?
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 06:03:46 pm
Unfortunatly, no.
Title: Re: Help With Nymless!
Post by: LincolnB on August 20, 2011, 06:04:44 pm
What the heck does this do?

E15->{L1}r
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 08:36:20 pm
That's so it knows that I'm talking about an Appvar
Title: Re: Help With Nymless!
Post by: LincolnB on August 20, 2011, 09:30:57 pm
oh wait -- I remember know how that works. But why the E?

EDIT: also, look at this:
GetCalc(Str1,0)->Q
why would you want an appvar that is zero bytes large?
Title: Re: Help With Nymless!
Post by: FinaleTI on August 20, 2011, 09:36:29 pm
oh wait -- I remember know how that works. But why the E?

EDIT: also, look at this:
GetCalc(Str1,0)->Q
why would you want an appvar that is zero bytes large?
E allows you to store a number using hexadecimal notation.
Just like pi allows you to store a number using binary notation.
Title: Re: Help With Nymless!
Post by: LincolnB on August 20, 2011, 09:40:42 pm
Ok. Yeah, that makes sense. Good to know. :)
Title: Re: Help With Nymless!
Post by: Freyaday on August 20, 2011, 11:11:09 pm
RE: 0 Byte Appvar:/me facepalms
Title: Re: Help With Nymless!
Post by: LincolnB on August 20, 2011, 11:18:28 pm
Was that one the problem? Or is it still not working?
Title: Re: Help With Nymless!
Post by: Darl181 on August 20, 2011, 11:46:12 pm
So it wasn't crashing, it just did nothing?
Title: Re: Help With Nymless!
Post by: Freyaday on August 21, 2011, 12:06:08 am
buttsfredkin: Nope. That's not the problem.
Darl181: Nah, it's crashing.
Title: Re: Help With Nymless!
Post by: LincolnB on August 21, 2011, 12:13:30 pm
Quote
Copy(P,V+W,length(P))

are you sure you want to be using P here, not L1 or the pointer to L1? Because P is just a string of tokens.

Also, I'm confused here:
Quote
If B
because B is never defined, ever, in your code so far (as far as I can tell)

Here's a good debugging technique: comment out everything but the first line. Then compile and run the code. If it doesn't crash, that line is not the problem line. Then, go back into the source and un-comment the second line (if the second line is some kind of If statement or something like that that requires an 'End', un-comment as much as you have to for the control structure to be valid). Compile and run the code. If it doesn't crash, whatever you just un-commented is not the problem. Et cetera et cetera repeat ad infinitum forever and ever worlds without end, amen. Once you have it narrowed down to one line that's causing the problem, it's easy to fix.

Let me know if that works :)