Omnimaga
Calculator Community => TI Calculators => General Calculator Help => Topic started 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?
-
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
-
Ah ok. That's what I thought. Now just for Z to answer the part about Rcl :P
Thanks, Builderboy.
-
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
-
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 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
-
Basicly, with Rcl you can recall certain numbers into your code. So say this happens: You have a program that looks like
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.
-
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.
-
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.
-
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.
-
iooh ok yeah he fixed it in his post now
I do that often too
-
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.
-
Basicly, with Rcl you can recall certain numbers into your code. So say this happens: You have a program that looks like
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.
-
Basicly, with Rcl you can recall certain numbers into your code. So say this happens: You have a program that looks like
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.
-
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.
-
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
-
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
-
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 ':'.
-
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.
-
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
-
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.
-
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.
-
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:
":ATTACK1:randInt(5,10):→Str7
":ATTACK2:randInt(5,10):→Str6
...
or 2.
":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:
"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 :(
-
sorry, should have explained it a little better, here goes:
"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.
-
Oh ok, so Str7 changes depending on the the attack chosen by the user?
-
yeah
-
Hmmm, ok. That makes sense. Would
"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?
-
@_player
Did you find a good way to do it?
-
sorry, haven't tried it yet, working on a couple other projects, I'll test it in a minute :)
-
Oh ok, sounds good.
-
Hey _player, did you ever get this to work?
-
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
-
Oh that sucks :(
-
sorry to hear :(