SRL Archive - Jr. Member General Help and Discussion

Basic global variables question


Thomas

2015-04-22 09:54:02

Hey,

If I use the a global variable like this:
SellPrice := round(grandExchange.getPrice(x) * 1,1);

Does it get recalculated every time I call it in other functions? Or just calc it the first time it get's called and remain that number?


*edit*
Pretty sure it doesn't get updated, any way to do this but still keep it global?

Regards,
Thomas

riwu

2015-04-22 11:23:59

so you want it to recalculate every time you use it? then you just have to use the expression on the right (i.e. round(grandExchange.getPrice(x) * 1,1) – can make it a fn for simplicity) every time.

Thomas

2015-04-22 11:31:57

Ye, that's what I did :)
Thanks though!

honeyhoney

2015-05-06 18:02:27

The variable will remain at the value you set it to when it was instantiated, unless you explicitly reassign it to another value.

Edit: removed my suggestion, it is definitely best to use a wrapper function for this case.

//not sure if getPrice() accepts string (item name) or int (item id)
function getSellPrice(item: String): Integer;
begin
Exit(round(grandExchange.getPrice(item) * 1,1));
end;