SRL Archive - RS3 Help

Getting a comma out of an integer


Ross

2014-08-17 09:04:53

I'm trying to pull prices from the RS wiki, but when I pull the price string to convert it to an integer it tries to take the comma with it. Any ideas on how I can make this not happen?

bonsai

2014-08-17 09:19:13

From: therossity
I'm trying to pull prices from the RS wiki, but when I pull the price string to convert it to an integer it tries to take the comma with it. Any ideas on how I can make this not happen?


Something like this should take your commas out.

mystring := replace(mystring, ',', '', [rfReplaceAll]);

Ross

2014-08-17 09:23:56

From: bonsai
Something like this should take your commas out.

mystring := replace(mystring, ',', '', [rfReplaceAll]);


Genius, worked great. Thank you!

The Mayor

2014-08-17 17:04:17

From: therossity
Genius, worked great. Thank you!


Or you could just extract numbers only:

function getGEPrice(itemString: string): integer;
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
priceString := between('GEPrice">', '</span>', wikiaPage);
result := strToIntDef(ExtractFromStr(priceString, numbers), -1);
end;

getGEPrice('Iron_ore');


Ross

2014-08-17 17:09:35

From: The Mayor
Or you could just extract numbers only:

function getGEPrice(itemString: string): integer;
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
priceString := between('GEPrice">', '</span>', wikiaPage);
result := strToIntDef(ExtractFromStr(priceString, numbers), -1);
end;

getGEPrice('Iron_ore');




Hey now, that's nifty! That will shave a couple lines off of my script for sure! 6 types of hide, 6 types of leather :P