Results 1 to 7 of 7

Thread: Checking Boolean causes Error: Out of Global Vars range

  1. #1
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default Checking Boolean causes Error: Out of Global Vars range






    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:
    Simba Code:
    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.

  2. #2
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    The problem is that you have run out of global variables which is indeed the case.
    Simba Code:
    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
    Simba Code:
    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.

    Script source code available here: Github

  3. #3
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by J J View Post
    The problem is that you have run out of global variables which is indeed the case.
    Simba Code:
    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
    Simba Code:
    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?

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    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.
    Working on: Tithe Farmer

  5. #5
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Alright then thanks both of you for the clarification ^^

  6. #6
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Lol wtf? We need to ditch Pascal..

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

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

    vs.

    Simba Code:
    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.
    I am Ggzz..
    Hackintosher

  7. #7
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Lol wtf? We need to ditch Pascal..

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

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

    vs.

    Simba Code:
    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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •