Author Topic: Displaying 7 digit numbers  (Read 610 times)

I know this is my second post here today, sorry, but I cannot for the life of me figure out how to get this to work.
I have an amount of money that is 7 digits, and it displays like this:
You have $1.10011e+006

 you can't unless you handle it as a string.

torquestuff has a limitation on numbers

How would I send back all bank data as a string?
Code: [Select]
function Sassy::getData(%this, %ID)
{
for(%a = 0; %a <= %this.dataCount; %a++)
{
if(%this.data[%a].ID == %ID)
{
return %this.data[%a];
}
}

return false;
}

Bank value is fetched by CityRPGData.getData(%client.bl_id).valueBank
If you need any other info just ask

How would I send back all bank data as a string?
Code: [Select]
function Sassy::getData(%this, %ID)
{
for(%a = 0; %a <= %this.dataCount; %a++)
{
if(%this.data[%a].ID == %ID)
{
return %this.data[%a];
}
}

return false;
}

Bank value is fetched by CityRPGData.getData(%client.bl_id).valueBank
If you need any other info just ask
As long as you don't do calculations with it (+, -, *, /, <, >) it will stay as a string

This is how I do it. I change it into a string by adding a , in the appropriate places.

Code: [Select]
function handleBigNumberC(%aNumber) //Function made by Red_Guy
{
%pos = strPos(%aNumber, "e+");

if(%pos == -1)
{
return %aNumber;
}

if(getSubStr(%aNumber, 0, 1) $= "-")
{
%sign = "-";
%aNumber = getSubStr(%aNumber, 1, strlen(%aNumber) - 1);
}

%posDec = strPos(%aNumber, ".");
%zeroes = "00000000000000";
//         12345678901234
//  handle up to e+014

if(%posDec == -1)
{
// no decimal pt. so number is like 1e+006
%newNumber = getSubStr(%aNumber, 0, 1) @ %zeroes;
}
else
{
%newNumber = getSubStr(%aNumber, 0, 1) @ getSubStr(%aNumber, %posDec + 1, %pos - (%posDec+1)) @ %zeroes;
}

%digits = getSubStr(%aNumber, %pos + 2, 3);
%newNumber = getSubStr(%newNumber, 0, %digits + 1);
%this = %sign @ %newNumber;

return %this;
}

function handleBigNumberB(%aString) //Function made by Red_Guy
{
%len = strlen(%aString);

if(%len < 4)
{
return %aString;
}

%last = getSubStr(%aString, %len - 3, 3);
%first = getSubStr(%aString, 0, %len - 3);
%part = handleBigNumberB(%first);
%this = %part @ "," @ %last;

return %this;
}

function handleBigNumber(%aString) //Function made by Red_Guy
{
if(getSubStr(%aString, 0, 1) $= "-")
{
%this = "-" @ handleBigNumberB(handleBigNumberC(getSubStr(%aString, 1, strlen(%aString))));
}
else
{
%this = handleBigNumberB(handleBigNumberC(%aString));
}

return %this;
}

Just do handleBigNumber(number); and it will return the string.

Just do handleBigNumber(number); and it will return the string.

How would I use that in this?
Code: [Select]
function Sassy::getData(%this, %ID)
{
for(%a = 0; %a <= %this.dataCount; %a++)
{
if(%this.data[%a].ID == %ID)
{
return %this.data[%a];
}
}

return false;
}
Sorry, I literally have no idea how these for/return functions work.