SRL Archive - OSR Help

Checking Boolean causes Error: Out of Global Vars range


riwu

2012-10-13 22:01:16




There is no difference between the 2 except that that if i check for the result of FindDeformedBitmapToleranceIn it will return an error.
Any idea what's causing the error?

Here's the code that you can try out:
program new;
{$DEFINE SMART}
{$I SRL/SRL.simba}

procedure OutOfRange;
var
i,bmpOrt,x,y: Integer;
ortAcc: Extended;
begin
bmpOrt := BitmapFromString(10, 16, 'meJxt0csKglAQxvGHKQihkkS7GhVmUJnUoQtiUla2KNrVohZBl0WLIKIH6FX7YGAQDf648DeHM2iyO0y0BSrrOidGY7TebEuHW3F/SbsBk78K0GyxxADUfH2RnFOYqI7V03ZHIsqy+1zt+m4YTS1foOyBcKbeXwWR8gArESsNQA2zxRQZwJKV0yOTlVFEsbA396F4QwM0A8JdYUWKqnKs9fsH4XZ8GSZW7Iwngk4cF4U1HCktEFc6DkpJEv2a+HEQqp6f6AeAVpTc');

for i:=1 to 28 do
begin
FindDeformedBitmapToleranceIn(bmpOrt,x,y,InvBox(i).X1,InvBox(i).Y1,InvBox(i).X2,InvBox(i).Y2,10,0,true,ortAcc);
if ortAcc>0.5 then
begin
writeln(i);
Break;
end;
end;

FreeBitmap(bmpOrt);
end;

begin
SetupSRL;
OutOfRange;
end.

J J

2012-10-14 06:58:20

The problem is that you have run out of global variables which is indeed the case.
InvBox(i).X1,InvBox(i).Y1,InvBox(i).X2,InvBox(i).Y2
4*28 = 112 variables you are using in the loop

Define a Box as TBox and do
Box := IntToBox(InvBox(i).X1,InvBox(i).Y1,InvBox(i).X2,InvBox(i).Y2)
Then change the code to Box.X1, Box.Y1, Box.X2, Box.Y2

Otherwise you are having too many global variables that are getting generated.

riwu

2012-10-14 07:25:19

From: J J
The problem is that you have run out of global variables which is indeed the case.
InvBox(i).X1,InvBox(i).Y1,InvBox(i).X2,InvBox(i).Y2
4*28 = 112 variables you are using in the loop

Define a Box as TBox and do
Box := IntToBox(InvBox(i).X1,InvBox(i).Y1,InvBox(i).X2,InvBox(i).Y2)
Then change the code to Box.X1, Box.Y1, Box.X2, Box.Y2

Otherwise you are having too many global variables that are getting generated.

Does the 'global variable' refer to total amount of variables? (i declared it locally) And how does adding an 'if then' affects it?

Btw you can just do Box:=InvBox(i), i didn't like to declare an extra box variable unnecessarily, why Simba put a cap on it? Does these small data variables take out so much memory for it to worry about?

masterBB

2012-10-14 07:29:26

The way you do it is a tiny bit slower then InvBox(i) to a variable. It seems to me like a pascalscript bug though. In this case it would be good practice to replace it with a variable anyway.

riwu

2012-10-14 07:32:03

Alright then thanks both of you for the clarification ^^

Brandon

2012-10-14 09:37:12

Lol wtf? We need to ditch Pascal..

Lape has something similar to this and it's for booleans too.


var
A, B: Boolean;
begin
A := True;
B := True;
writeln(A xor B); //Writes False.
end.

vs.


var
A, B: Boolean;
begin
A := True;
B := (Length(SomeTPA) > 0); //SomeTPA has 7 points.
writeln(A xor B); //Writes True.. Wtf? True XOR True Resulting in True :S..
end.

riwu

2012-10-14 10:19:30

From: Brandon
Lol wtf? We need to ditch Pascal..

Lape has something similar to this and it's for booleans too.


var
A, B: Boolean;
begin
A := True;
B := True;
writeln(A xor B); //Writes False.
end.

vs.


var
A, B: Boolean;
begin
A := True;
B := (Length(SomeTPA) > 0); //SomeTPA has 7 points.
writeln(A xor B); //Writes True.. Wtf? True XOR True Resulting in True :S..
end.

Wow that's crazily weird. You could even just make B:= (0 = 0), and writeln(B) returns true but it passed to xor as false? Are these bugs fixable in Simba since they could cause unintended results in scripts? (esp. since no compiling error occurs)

If not we may have to start a section compiling all the bugs in pascal/lape so that others are aware of them?