TomTuff
2011-06-20 15:15:09
function CashStringToInt(S: string): Integer;
var
i, ii: Integer;
Numbs: TStringArray;
Temp: string;
begin
Temp := '';
Numbs := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'k', 'm', 'b'];
for i := 1 to High(S) do
for ii := 0 to High(Numbs) do
if S[i] = Numbs[ii] then
case ii of
0..9: Temp := Temp + Numbs[ii];
10..12:
begin
Result := StrToInt(Temp);
case ii of
10: Result := Result * 100; //Since price is given to 1 decimal,
11: Result := Result * 100000; //instead of multiplying by the entire
12: Result := Result * 100000000; //factor, you must multiply by factor/10
end;
end;
end;
if (Result = 0) then
Result := StrToInt(Temp);
end;
function GetPrice(ItemID: Integer): Integer;
begin
Result := CashStringToInt(Between('<b>Current guide price:</b>', '<br><br>', GetPage('http://services.runescape.com/m=itemdb_rs/Shark/viewitem.ws?obj=' + ToStr(ItemID))));
end; This works with items that have the suffix "K", "M", "B", etc after them and only requires the object ID. I know that this might be considered "Using reflection" since it uses the item ID, but it could be used with just SRL to calculate things like profit/hr (or loss per hour :p) even in a color script.
use:
price := GetPrice(ID_Item); //ID_Item is some const