Hi Jimmi,
I made a class that does just that (and a little bit more).
I can send it to you off list if you wish.
HTH,
Willem van den Goorbergh
Op 3-apr-2009, om 10:19 heeft jimmi het volgende geschreven:
Good morning,
I have made a function that adds interpunction marks to a value, for
example the value 10000 gets changed to 10.000, 100000 to 100.000 and
so forth.
The function work fine, but I'm trying to make it reusable so that i
can use it in a large scale project. That's where the problem comes
up.
This is what the working code looks like:
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
var outputNumber:Number = 10000 // input value
var outputString:String = new String();
function init ()
{
outputString = String(Number(outputNumber));
interpunk (outputString);
trace(outputNumber); // output is 10000
trace(outputString); // output is 10.000
}
function interpunk (par1):Void
{
trace(par1)
switch (par1.length)
{
case 4 :
outputString = String(par1.charAt (0) + "." +
par1.slice (1))
break;
case 5 :
outputString = String(par1.charAt (0) + par1.charAt (1) +
"." +
par1.slice (2))
break;
case 6 :
outputString = String(par1.charAt (0) + par1.charAt (1)
+
par1.charAt (2) + "." + par1.slice (3))
break;
default :
outputString = String(par1)
break;
}
}
init ();
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
So i tried to make it reusable, so i tried this(changed
outputString to par1).
But now the value comes out unchanged so 10000 stays 10000, while i
expected it to become 10.000.
I hope someone can help i the right direction.
This is what the non working code looks like :
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
function interpunk (par1):Void
{
trace(par1)
switch (par1.length)
{
case 4 :
par1 = String(par1.charAt (0) + "." + par1.slice (1))
break;
case 5 :
par1 = String(par1.charAt (0) + par1.charAt (1) + "." +
par1.slice (2))
break;
case 6 :
par1 = String(par1.charAt (0) + par1.charAt (1) +
par1.charAt (2) +
"." + par1.slice (3))
break;
default :
par1 = String(par1)
break;
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Geografiek is a Dutch, Utrecht-based map and chart design company.
Willem van den Goorbergh can be contacted by telephone: (+31)
30-2719512 or cell phone: (+31)6-26372378
or by fax: (+31)302719687
snail mail: Hooghiemstraplein 89 3514 AX UTRECHT
Visit our website at: http://www.geografiek.nl
=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders