Code center > Bugs and fixes

Let's make a stable platform

<< < (7/26) > >>

Numsgil:
Ah, that would be a no, Bots.
The fix isn't too bad.  Store the memrefvelup or whtatever and the other one to longs.  Then square each one and add them together.  Then find the square root.  Then double check to see that that isn't > 32000.

Welcome to my world ;)

Just so we're clear, PY is handling all the debugging of 2.37.4.  I'm working on other things (like robot placement code ;) (speaking of which... Bots, you have heard of thiis little button on the left of the keyboard called a 'tab', right?)

PurpleYouko:

--- Quote ---Where are you PY??? 
--- End quote ---

Give me a chance dude.

I only initiated this yesterday and I do actually have a life (and a job) outside DB. Sometimes I can't even get to the code for a week at a time.

Let's start at the beginning. (No offense intended if you already know this stuff)

As Bots suggested, hovering the mouse over a variable is the best way to find out what is wrong.

The most common problem seems to be "overflow"

This simply means that the result of a calculation is too big to fit within the variable type.
Most DB variables are defined as "single" (single precision floating decimal) or "integer". Both of these memory types assign 16 bits of memory to hold the value. That is 1*2*2*2*2*2*2*2*2*2*2*2*2*2*2 possible combinations. Otherwise known as a maximum value of 32,768. We normally limit it to 32000 for an easier life.

So what happens is that some calculation results in a value greater than 32768 then tries to store it into a variable that can't hold it. Instant overflow and the program gives up in disgust.

By hovering the mouse, you can often find the exact variable or calculation that is causing the problem.

You need to report the line of code with as much information about the actual variables as possible. It also helps a lot to report the name of the subroutine in which the code is located. It can be an extremely daunting task just trying to find a specific line of code in the program without a little more info to go on.
In the case of a relatively small routine, just copy the whole routine and put it inside "code" tags in your message. Then describe the problem.

Hopefully I can look into some of this stuff later today.

Numsgil:
Haha, okay.  Let's do this bit by bit:


--- Quote ---Here's that Run-Time error 6 bug, appeared after a one hour long simulation.

rob(n).mem(refvelscalar) = Sqr(rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2) ' how fast is this robot moving compared to me?
--- End quote ---

velocity should never be > 60, so theoretically rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2 should always be <= 3600, well within the range of an integer.

That it isn't is cause for concern, because it means somewhere something is acting screwy.  Oh well, that's life.  To fix it so this doesn't overflow, we do:

dim temp as single

temp = rob(n).mem(refvelup) ^ 2 + rob(n).mem(refveldx) ^ 2
temp = sqr(temp)

rob(n).mem(refvelscalar) = temp

and then you test it, cause overflow errors like this are always a pain in the butt, and often fixes that should work don't.

Botsareus:

--- Quote ---Bots, you have heard of thiis little button on the left of the keyboard called a 'tab', right?
--- End quote ---

 :blink:
I dont get it; Yes I have... and?


MY CODE < USE MY CODE! ... :( ... (What really bugs me is: what if you fix something in some other ways then I fixed it and suddenly 'poof' my robots that I got from my code don't work on your code)

Numsgil:
And your code lacks standard tabbing.  Things like indenting at the start of a function, for instance.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version