Spaceblow
2014-08-18 07:59:16
Yes I know, in the recent past I've already made a few threads in this section asking some pretty obvious question but I only do that if I've already tried some time to figure it out and if I still don't know what to do. So I want to get the actual GE prices, I tried to figure out by looking at…
The Mayor's snippet:
But I really don't know what he's talking about. I would rather want to understand everything from his snippet than just copy it into my script. I placed numbers in his snippet for asking my questions:
#1: I don't understand why he's doing
#2: There's a lot I don't understand here. I get that with

But nothing matches with his lines? And then he has also this:
#3: So I guess that with
And for stuff like:
#4: Again, there's a lot I don't understand, almost nothing to be honest. Why is it being assigned as 'result' if that's not even being used? And if I read this:
To be honest, it took me a while to make this thread. I hope you guys could answer my questions so I could understand everything I type instead of just leeching someone's snippet. Thanks in advance!
The Mayor's snippet:
const
EXCHANGE_PRICE = 1;
LOW_ALCH = 2;
HIGH_ALCH = 3;
function getItemPrice(itemString: string; priceType: integer): integer; //#1
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
case priceType of
1: priceString := between('GEPrice">', '</span>', wikiaPage); //#2
2: priceString := between('<b>Low Alchemy:</b> ', '</li>', wikiaPage); //#3
3: priceString := between('<b>High Alchemy:</b> ', '</li>', wikiaPage);
end;
result := strToIntDef(ExtractFromStr(priceString, numbers), -1); //#4
end;
begin
clearDebug;
writeLn('Fire orb GE price: ' + toStr(getItemPrice('Fire_orb', EXCHANGE_PRICE)));
writeLn('Fire orb Low Alch price: ' +toStr(getItemPrice('Fire_orb', LOW_ALCH)));
writeLn('Fire orb High Alch price: ' +toStr(getItemPrice('Fire_orb', HIGH_ALCH)));
writeLn('Purple Phat GE price: ' + toStr(getItemPrice('Purple_partyhat', EXCHANGE_PRICE)));
end.Fire orb GE price: 3194
Fire orb Low Alch price: 120
Fire orb High Alch price: 180
Purple Phat GE price: 1175384160
Successfully executed.But I really don't know what he's talking about. I would rather want to understand everything from his snippet than just copy it into my script. I placed numbers in his snippet for asking my questions:
#1: I don't understand why he's doing
(itemString: string; priceType: integer): integer;I always wondered why people put those stuff between paretheses when I looked at their scripts. Is it because it's a function that you have to do it? I mean, why don't they just put it under var and declare it there? And the: integer; is used for getItemPrice and not the stuff between the paretheses, right?#2: There's a lot I don't understand here. I get that with
'GEPrice">'he's looking for text. But why is there a " and a > ? If for example I want to get the fire orb GE price and I go to the fire orb wikia. And I search (CTRL + F) for 'GEPrice' I can't find it, so why does he use that then? I guess he's aiming for this:
But nothing matches with his lines? And then he has also this:
'</span>'What is it for? I looked it up and <span>…</span> looks for a piece of text on the webpage, but why does he only use the second part of it? I mean, what is he closing with the trailing slash if he didn't even use the first part of it?#3: So I guess that with
'<b>Low Alchemy:</b> 'he's looking for the text 'Low Alchemy' that's written in bold. But then comes this:'</li>'Again, what is it used for? I really have no idea, and why does it only have the second part of it (the part with the trailing slash)?And for stuff like:
between(..., ..., ...);Is it somewhere in the SRL-6 docs or do we have to figure it out by ourselves?#4: Again, there's a lot I don't understand, almost nothing to be honest. Why is it being assigned as 'result' if that's not even being used? And if I read this:
strToIntDefI understand:string To Integer ???So I really don't know what he means with 'Def'. And after 'Def' he has:(ExtractFromStr(priceString, numbers), -1);I really don't understand anything of that, simply nothing… Could someone clarify this for me please?To be honest, it took me a while to make this thread. I hope you guys could answer my questions so I could understand everything I type instead of just leeching someone's snippet. Thanks in advance!


