Hi,
I simple cannot figure how to convert Jagex's GE prices to a number:
I would have a number like 146.0k and would like to convert it to 146000. How would i go around that?
Hi,
I simple cannot figure how to convert Jagex's GE prices to a number:
I would have a number like 146.0k and would like to convert it to 146000. How would i go around that?
Pseudo code:
if FindLetterK then
begin
int i;
PutNumersIntoVariable(i);
i := i * 1000;
end;
Like that? Just check if there is a K after the number, then get the numbers into a string and convert to integer, then multiply the integer number by 1000 and it should give you the real val. I don't know if you would use FindText or what, so you'd have to pick the function(s).
146.0 * k (1000)
Get the letter after the last number (if there is one) and multiply by one, one thousand, or one million.
:-)
SCAR Code:function ConvertNumber(N: String): Integer;
begin
if (Pos('k', N) <> 0) then
begin
N := TrimLetters(N);
if (Pos('.', N) <> 0) then
N := Replace(N, '.', ',');
Result := StrToInt(N) * 1000;
end;
Writeln(Result);
end;
This is what I got? It fails at converting to an int, why?






Thanks guys, this is what I ended up with:
SCAR Code:function ConvertNumber(N: String): Integer;
begin
if (Pos('k', N) <> 0) then
begin
N := Trim(Replace(N, 'k', ''));
Result := Round(StrToFloat(N) * 1000.0);
end;
Writeln(Result);
end;
Works for k and m. Your last snippet doesn't remove the comma's as well, so may be an issue.SCAR Code:function ConvertPrice(input: string): Integer;
var
f: Extended;
begin
input := Replace(Lowercase(Trim(input)), ',', '');
if (Pos('m', input) > 0) then
f := StrToFloatDef(Copy(input, 1, Pos('m', input) - 1), 0) * 1000000
else if (Pos('k', input) > 0) then
f := StrToFloatDef(Copy(input, 1, Pos('k', input) - 1), 0) * 1000
else
f := StrToFloatDef(Input, 0);
Result := Round(f);
end;
By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.
There are currently 1 users browsing this thread. (0 members and 1 guests)