SRL Archive - OSR Help

Out of range


weequ

2010-04-08 07:06:08

Solved.

Naum

2010-04-08 07:15:43

You need to set the length of T2D, I think.

Would you mind showing the whole script? Could be a problem with the array NoFindBoxes aswell.

weequ

2010-04-08 07:21:33

From: Naum
You need to set the length of T2D, I think.

Would you mind showing the whole script? Could be a problem with the array NoFindBoxes aswell.

I edited with the whole script ;)
And btw it just worked once but 95% of the time it gets the error :D

Wanted

2010-04-08 11:05:52

Might be because you mess with the Length of T2D in the middle of a loop (shortening it) and then when it goes to the next step in the loop its out of range because the high is smaller. " SetArrayLength(T2D, L2-1);" <-> "for II := 0 to High(T2D) do"

weequ

2010-04-08 12:00:26

From: IceFire908
Might be because you mess with the Length of T2D in the middle of a loop (shortening it) and then when it goes to the next step in the loop its out of range because the high is smaller. " SetArrayLength(T2D, L2-1);" <-> "for II := 0 to High(T2D) do"

But as you can see I have that WriteLn('a'); in that function and it only prints it once so it can't have gone that far in the script :(

Edit: You can only see in the whole script :P

Wanted

2010-04-08 13:55:53

From: antti mies
But as you can see I have that WriteLn('a'); in that function and it only prints it once so it can't have gone that far in the script :(

Edit: You can only see in the whole script :P


That's in a different spot

    for II := 0 to High(T2D[I]) do    
for III := 0 to High(NoFindBoxes) do
if PointInBox(T2D[I][II], NoFindBoxes[III]) then
begin
L := High(T2D[I]);
Swap(T2D[I][II], T2D[I][L]);
L2 := Length(T2D[I])
SetArrayLength(T2D[I], L2-1);
end;

weequ

2010-04-09 01:36:59

Ok i think ill do some more debugging but now i have to go school :)

weequ

2010-04-10 09:47:39

Thanks icefire.
All I had to do was to add a break;

for II := 0 to High(T2D[I]) do   
for III := 0 to High(NoFindBoxes) do
if PointInBox(T2D[I][II], NoFindBoxes[III]) then
begin
L := High(T2D[I]);
Swap(T2D[I][II], T2D[I][L]);
L2 := Length(T2D[I])
SetArrayLength(T2D[I], L2-1);
Break; // <---- HERE
end;