Omnimaga

Calculator Community => TI Calculators => General Calculator Help => Topic started by: meishe91 on April 11, 2010, 01:04:10 am

Title: Debugging on the Calculator
Post by: meishe91 on April 11, 2010, 01:04:10 am
So I've been seeing the term "debug" or "debugging" be tossed around here and there and was curious what is meant by it exactlly. I also saw Ztrumpet say that he uses Rcl to help debug too. Can anyone explain this?
Title: Re: Debugging on the Calculator
Post by: Builderboy on April 11, 2010, 01:10:07 am
Debugging is simply fixing problems with your code so that it will work correctly.  Often times in games bugs can be hard to find, so to debug your games, you will both run the game through a couple times, and also try to get into weird scenarios that are not expected, trying to find problems.

As for using Rcl, i dont know what he was using it for o.O
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 11, 2010, 01:12:26 am
Ah ok. That's what I thought. Now just for Z to answer the part about Rcl :P

Thanks, Builderboy.
Title: Re: Debugging on the Calculator
Post by: DJ Omnimaga on April 11, 2010, 01:30:40 am
So I've been seeing the term "debug" or "debugging" be tossed around here and there and was curious what is meant by it exactlly. I also saw Ztrumpet say that he uses Rcl to help debug too. Can anyone explain this?
It's when we want to grab a hammer and smash our calc when trying to get our programs to work.

J/k, what Builderboy said :P
Title: Re: Debugging on the Calculator
Post by: Builderboy on April 11, 2010, 01:32:39 am
Or it could be like what weregoose does where he just keeps putting together random tokens until he gets the most efficient and speedy solution. ;)
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 11, 2010, 01:38:15 am
Or it could be like what weregoose does where he just keeps putting together random tokens until he gets the most efficient and speedy solution. ;)

Or smallest :P
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 11, 2010, 02:10:06 am
Basicly, with Rcl you can recall certain numbers into your code.  So say this happens:  You have a program that looks like
Code: [Select]
For(A,1,10)
output(A,A/2,"A")
End
well, when you run this you get a domain error.  So you press 2 to goto the part of your code.  But then you want to look at what number it was that messed your code up, but don't want to go to the homescreen.  So you press [2nd][Rcl] and then A to recall A into your code.  Now you can see exactly what number messed up your code.  Its a pretty useful method imo.  If that doesn't make sense tell me.
Title: Re: Debugging on the Calculator
Post by: DJ Omnimaga on April 11, 2010, 02:19:50 am
output(A,A/2) doesN,t that give an ERR:ARGUMENT/SYNTAX error?

Also to check if a If/while/repeat/for loop/condition is not missed, I add + at the beginnign of it so if I get ERR:SYNTAX, it's ran correctly, then I move the + a few lines lower, try again.

Also for missing/too many Ends, what you can do in your head is start with the number 0, then everytime a Then/while/repeat/for is encountered, increment by 1, and when a End is encountered, decrement by 1. If at the end it's higher than 0, an End is missing somewhere. If it's lower, then you have too many.

TI-BASIC has this annoying limitation of not having EndIf, EndRepeat, EndWhile or EndFor instructions. In other languages, it makes code much easier to read.
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 11, 2010, 02:22:12 am
woops, yeah I'll fix that.  And I also use that too many/few Ends trick.  Never tried the other one I ussually use a pause instead.
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 11, 2010, 02:26:30 am
That does make a lot of sense, would have been useful to know that a few days ago :P
And thanks for the tips DJ.
Title: Re: Debugging on the Calculator
Post by: DJ Omnimaga on April 11, 2010, 02:27:30 am
iooh ok yeah he fixed it in his post now

I do that often too
Title: Re: Debugging on the Calculator
Post by: Raylin on April 11, 2010, 11:05:30 am
Debugging is a magical thing that lets you kill the bugs in your program.

Also, I agree with player.
Recalling the last value is a great technique.
Use it often.
Title: Re: Debugging on the Calculator
Post by: ACagliano on April 11, 2010, 12:28:43 pm
Basicly, with Rcl you can recall certain numbers into your code.  So say this happens:  You have a program that looks like
Code: [Select]
For(A,1,10)
output(A,A/2,"A")
End
well, when you run this you get a domain error.  So you press 2 to goto the part of your code.  But then you want to look at what number it was that messed your code up, but don't want to go to the homescreen.  So you press [2nd][Rcl] and then A to recall A into your code.  Now you can see exactly what number messed up your code.  Its a pretty useful method imo.  If that doesn't make sense tell me.

That actually is pretty easy. Row/column numbers used in output can only be whole numbers, so for the statement For(A,1,10), A will be troublesome every other number. That is not a hammer situation. I can show you a hammer situation.
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 11, 2010, 12:34:25 pm
Basicly, with Rcl you can recall certain numbers into your code.  So say this happens:  You have a program that looks like
Code: [Select]
For(A,1,10)
output(A,A/2,"A")
End
well, when you run this you get a domain error.  So you press 2 to goto the part of your code.  But then you want to look at what number it was that messed your code up, but don't want to go to the homescreen.  So you press [2nd][Rcl] and then A to recall A into your code.  Now you can see exactly what number messed up your code.  Its a pretty useful method imo.  If that doesn't make sense tell me.

That actually is pretty easy. Row/column numbers used in output can only be whole numbers, so for the statement For(A,1,10), A will be troublesome every other number. That is not a hammer situation. I can show you a hammer situation.
ok, I was just out of examples, it works really well in whatever code I have that messes up.
Title: Re: Debugging on the Calculator
Post by: ACagliano on April 11, 2010, 12:41:49 pm
I never actually thought of using Rcl. I use Pause mostly when testing loops. For variable-based errors, I usually take hours to figure out where they are. lol. Thanks for the idea.
Title: Re: Debugging on the Calculator
Post by: ztrumpet on April 14, 2010, 07:52:24 am
It's a great technique.  In fact, I think everyone's debugged before even if they don't know the term. ;D
Rcl is useful for the reasons stated above. :)  Thanks player for the great explanation! :D
Title: Re: Debugging on the Calculator
Post by: DJ Omnimaga on April 14, 2010, 12:12:53 pm
One thing that is hard to debug it seems are logical errors x.x

I mean when you accidentally choose > instead of < and won't notice until later, then when it comes time to debug, you can't figure out why your If blocks and loops are skipped despite the right amount of End instructions x.x
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 14, 2010, 05:57:58 pm
oh, I hate when that happens.  Math errors are the worst things ussually (though the math I do is ussually stealing stuff from a string, and the right amount of it).  On that topic actually, I need a simple routine that will take a part of a string (starting at one ':') and ending at the next part, as in if the string was "aaa:bbb:ccc:" and you searched through it (starting at bbb:) it would return ccc.  kinda off topic, but my current method is just a loop that scans until it reaches the ':'.
Title: Re: Debugging on the Calculator
Post by: jsj795 on April 14, 2010, 06:26:04 pm
instring( is a good operation that can do that.
http://tibasicdev.wikidot.com/instring (http://tibasicdev.wikidot.com/instring)

I personally am sick of bugs making hnefatafl AI... They had so much bugs -_-;;; Still not done debugging
I personally use Pause to see where the error occurs, and counting ends. Although many times, I miscount End because I overlooked some area. When the conditionals get too complicated, I write the code on paper, and connect the Loop with End.
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 14, 2010, 06:47:38 pm
my old method for finding part of the string was a compicated series of Instring() to find the correct value, but it was getting annoying to have to think it through, so I just wrote the other one.  (for my rpg I'm working on).  It doesn't really matter I don't guess unless I want to use it insomething else
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 14, 2010, 08:08:46 pm
Can you explain what you need again, I don't think I quite understand what you're looking for (like what it needs to do). I would like to try to help.
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 14, 2010, 08:11:52 pm
basically, I have a string with the attack's name, followed and preceeded by a colon (ie ":attack1:randint(5,10):" )  I would need something that takes the "randint(5,10)" part.  "attack1" would be in str7.
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 14, 2010, 08:58:29 pm
Well I'm not sure if I'm still understanding this correctly but from what you've said I have two thoughts of what you mean (I don't know if either are correct).

1. You have code set up like this:

Code: [Select]
":ATTACK1:randInt(5,10):→Str7
":ATTACK2:randInt(5,10):→Str6
...

or 2.

Code: [Select]
":ATTACK1:randInt(5,10):ATTACK2:randInt(5,10):...→Str7
My guess is the second one. But one thing you could do is something along the line of:

Code: [Select]
"randInt(5,10randInt(3,15randInt(6,12→Str7 //Example string to get the attack value (I'm guessing that is the use of this?)
Prompt A //The attack number.
expr(sub(Str7,5A-4,5→B //Gets the randomly generated number.

(You can apply this method with the names involved. The only restriction is that the names need to be the same length along with the random generated numbers. If that makes sense.)

I mean again I don't know if this is the kind of thing you're looking for but that's what I figured out from what you've said. Sorry if it doesn't help much :(
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 14, 2010, 09:06:13 pm
sorry, should have explained it a little better, here goes:
Code: [Select]
"attack1->Str7
":attack1:randint(3,6):attack2:(randint(0,9001)>9000)*9000:->Str2
(code here to get the attack damage)
the second part where it picks the amount of damage can be a different size than the rest, and I would like to refrain from lists, as it is hard to add new attacks in.
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 14, 2010, 09:12:49 pm
Oh ok, so Str7 changes depending on the the attack chosen by the user?
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 14, 2010, 09:13:33 pm
yeah
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 14, 2010, 09:42:28 pm
Hmmm, ok. That makes sense. Would

Code: [Select]
"ATTACK1→Str7
":ATTACK1:randInt(5,10):ATTACK2:(randInt(0,9001)>9000)*9000:→Str2
inString(Str2,Str7)+1+length(Str7
expr(sub(Str2,Ans,inString(Str2,":",Ans)-Ans→B

work for what you need?
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 15, 2010, 07:15:57 pm
@_player
Did you find a good way to do it?
Title: Re: Debugging on the Calculator
Post by: _player1537 on April 15, 2010, 10:46:10 pm
sorry, haven't tried it yet, working on a couple other projects, I'll test it in a minute :)
Title: Re: Debugging on the Calculator
Post by: meishe91 on April 16, 2010, 12:19:48 am
Oh ok, sounds good.
Title: Re: Debugging on the Calculator
Post by: meishe91 on May 23, 2010, 08:07:25 pm
Hey _player, did you ever get this to work?
Title: Re: Debugging on the Calculator
Post by: _player1537 on May 23, 2010, 08:25:15 pm
sadly, I never got back into the rpg, so no :(
I went to try and get it set back up today and found that I had an old version, that didn't work, and didn't have all the stuff I coded in for enemy battle animations, or your own battle animations.  Sorry
Title: Re: Debugging on the Calculator
Post by: meishe91 on May 23, 2010, 08:41:02 pm
Oh that sucks :(
Title: Re: Debugging on the Calculator
Post by: DJ Omnimaga on May 23, 2010, 09:16:17 pm
sorry to hear :(