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?