Results 1 to 9 of 9

Thread: getExp()

  1. #1
    Join Date
    May 2011
    Location
    In an Island.
    Posts
    1,413
    Mentioned
    2 Post(s)
    Quoted
    149 Post(s)

    Default getExp()

    I would like to know why this keeps giving me this error:

    Error: "" is an invalid integer at line 24
    Code:
    program new;
    {$I SRL-6/SRL.simba}
    
    function getExp(): integer;
    var
        filter: TTesseractFilter;
        aux: String;
    begin
        with (filter) do
        begin
          multiplerW := 5;
          multiplerH := 5;
    
          with (thresholdSettings) do
          begin
            invert := False;
            amount := 0;
            method := TM_MEAN;
          end;
        end;
    
        aux := TesseractGetText(34,283,105,301, filter);
    
        Result := StrToInt(ExtractFromStr(aux,numbers));
    
        writeln(Result);
    
    end;
    
    begin
      getExp;
    end.
    ''If you want something you've never had, you have to do something you've never done''


    total leve 2715/1b exp +... exterminated.

  2. #2
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Code:
    Compiled successfully in 2637 ms.
    53
    Successfully executed.
    It works for me, make sure there is a text inside 34,283,105,301

  3. #3
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    It means you're passing an empty string to StrToInt most likely because it's reading numbers as letters because of a bad filter or something then ExtractFromStr is removing the letters. To stop access violations use StrToIntDef(text, -1); so if you do pass an invalid string it will default to -1 instead of erroring and stopping the script.
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  4. #4
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    ^ good point, StrToIntDef is a function which I use as default whenever I need to convert a string to integer, scripts are much more stable with it

  5. #5
    Join Date
    May 2011
    Location
    In an Island.
    Posts
    1,413
    Mentioned
    2 Post(s)
    Quoted
    149 Post(s)

    Default

    Weird.. Keeps giving me error..
    ''If you want something you've never had, you have to do something you've never done''


    total leve 2715/1b exp +... exterminated.

  6. #6
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Quote Originally Posted by onilika View Post
    Weird.. Keeps giving me error..
    Simba Code:
    program new;
    {$I SRL-6/SRL.simba}

    function getExp(): integer;
    var
        filter: TTesseractFilter;
        aux: String;
    begin
        with (filter) do
        begin
          multiplerW := 5;
          multiplerH := 5;

          with (thresholdSettings) do
          begin
            invert := False;
            amount := 0;
            method := TM_MEAN;
          end;
        end;

        aux := TesseractGetText(34,283,105,301, filter);

        Result := StrToIntDef(ExtractFromStr(aux,numbers), 0);

        writeln(Result);

    end;

    begin
      getExp;
    end.

    It works fine, just set correct TBox coordinates

  7. #7
    Join Date
    Oct 2012
    Posts
    1,258
    Mentioned
    40 Post(s)
    Quoted
    588 Post(s)

    Default

    Post a screenshot of what your rs window looks like? (censor out rsn ofcourse)

  8. #8
    Join Date
    Jul 2016
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    It works fine Scob helped me with this Thank you !

  9. #9
    Join Date
    May 2011
    Location
    In an Island.
    Posts
    1,413
    Mentioned
    2 Post(s)
    Quoted
    149 Post(s)

    Default

    Already did that.. perhaps is due to ogl..
    ''If you want something you've never had, you have to do something you've never done''


    total leve 2715/1b exp +... exterminated.

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
  •