Results 1 to 5 of 5

Thread: Help getting the GE price!

  1. #1
    Join Date
    Oct 2011
    Posts
    62
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Unhappy Help getting the GE price!

    Simba Code:
    program GEDB;
     {$i SRL\SRL.scar}

    function GetPrice(itemID: Integer): Integer;
      var
        price, page, itemName: String;
        tm, div_, xer_: Integer;
    begin
        MarkTime(tm);

        Page := GetPage('http://services.runescape.com/m=itemdb_rs/g=runescape/viewitem.ws?obj=' + IntToStr(itemID));
        Price := Between('<td>',' </td>', Page);
        ItemName := Between('<title>',' - Grand Exchange - RuneScape</title>', Page);
        Price := ReplaceWrap(Price, ',', ' ', [rfReplaceAll]);

        if (Price <> '') then
        begin
          if ( Length(Price) > Length(ReplaceWrap(Price, '.', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, '.', '', [rfReplaceAll]);
            div_ := 10;
          end;

          if ( Length(Price) > Length(ReplaceWrap(Price, 'k', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, 'k', '', [rfReplaceAll])
            WriteLn('"k" was found in the item price');
            xer_ := 1000;
          end else if ( Length(Price) > Length(ReplaceWrap(Price, 'm', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, 'm', '', [rfReplaceAll])
            WriteLn('"m" was found in the item price');
            xer_ := 1000000;
          end else if ( Length(Price) > Length(ReplaceWrap(Price, 'b', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, 'b', '', [rfReplaceAll])
            WriteLn('"b" was found in the item price');
            xer_ := 1000000000;
          end;
          WriteLn(price);
          Result := (StrToInt(Price) * xer_) / div_;
          WriteLn('The price of item ' + ItemName + ' is ' + IntToStr(Result) + 'gp');
        end else begin
          WriteLn('The price of the item was invalid');
          Result := (-1);
        end;

        WriteLn('This took ' + ToStr(TimeFromMark(tm)/1000.0) + ' seconds');

    end;


    begin
    ClearDebug;
    GetPrice(1038); //red partyhat
    end.

    OK so this to me looks like its meant to work but it returns a very wrong price.

    Code:
    "b" was found in the item price
    14
    The price of item Red partyhat is 111509811gp
    This took 1.529 seconds
    Successfully executed.
    so i get the number 14 for its price before i turn it into an integer thats fine

    but after i change it, multiply it by 1,000,000,000 and divide it by 10 it comes up with 111509811...!?!?...how does that work?

  2. #2
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Integers only go so far iirc. Why not just append a string of '000,000,000' to the integer.
    Ce ne sont que des gueux


  3. #3
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Have you tried this?

    Code:
     Result := ((StrToInt(Price) * xer_) / div_);
    And is the "div_" var being set?
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  4. #4
    Join Date
    Oct 2011
    Posts
    62
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    umm i'm not sure what floor66's means but in response to kyle...it was set on line 42

    E: oo i think i get what floor means...lemme try an do that then

    E2: nope...still stuck...i dont think i can use xer_ (meaning multiplier) as a string as then the result it returns wont be correct..
    Last edited by logical; 12-19-2011 at 04:19 PM.

  5. #5
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Try this:

    Simba Code:
    program GEDB;
     {$i SRL\SRL.scar}

    function GetPrice(itemID: Integer): Extended;
      var
        price, page, itemName: String;
        tm, div_, xer_: LongInt;
        res : Extended;
    begin
        MarkTime(tm);

        Page := GetPage('http://services.runescape.com/m=itemdb_rs/g=runescape/viewitem.ws?obj=' + IntToStr(itemID));
        Price := Between('<td>',' </td>', Page);
        ItemName := Between('<title>',' - Grand Exchange - RuneScape</title>', Page);
        Price := ReplaceWrap(Price, ',', ' ', [rfReplaceAll]);

        if (Price <> '') then
        begin
          if ( Length(Price) > Length(ReplaceWrap(Price, '.', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, '.', '', [rfReplaceAll]);
            div_ := 10;
          end;

          if ( Length(Price) > Length(ReplaceWrap(Price, 'k', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, 'k', '', [rfReplaceAll])
            WriteLn('"k" was found in the item price');
            xer_ := 1000;
          end else if ( Length(Price) > Length(ReplaceWrap(Price, 'm', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, 'm', '', [rfReplaceAll])
            WriteLn('"m" was found in the item price');
            xer_ := 1000000;
          end else if ( Length(Price) > Length(ReplaceWrap(Price, 'b', '', [rfReplaceAll])) ) then begin
            Price := ReplaceWrap(Price, 'b', '', [rfReplaceAll])
            WriteLn('"b" was found in the item price');
            xer_ := 1000000000;
          end;
          WriteLn(price);
          res := StrToInt(Price);
          res := res * xer_;
          res := res / div_;
          Result := Int(res);
          WriteLn('The price of item ' + ItemName + ' is ' + ToStr(Result) + 'gp');
        end else begin
          WriteLn('The price of the item was invalid');
          Result := (-1);
        end;

        WriteLn('This took ' + ToStr(TimeFromMark(tm)/1000.0) + ' seconds');

    end;


    begin
    ClearDebug;
    GetPrice(1038); //red partyhat
    end.
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


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
  •