-
is there an LPAD or RPAD function in ActionScript?
-
No, but you could throw one together pretty easily. Here, try this:
Code:
String.prototype.lpad = function(len, pad)
{
if( len > this.length )
{
var buf = '';
for( i = 0; i < len - this.length; i++)
{
buf += pad;
}
nes = buf + this;
}
else
{
nes = this;
}
return nes;
}
Use it like this:
myVar = 'Something';
myVar = myVar.lpad(15, '*');
myVar should be ******Something now. Hope this helps.
-
Thanks,
Thanks a great deal,
By the way when I performed an LPAD with 'spaces', the spaces just does NOT seem to align with the rest of my pattern in the field that I LPADed.
For example:
LPAD ("A", 5, "X") ---> would look like: "XXXXA", wherever
LPAD ("A", 5, " ") ---> would look like: " A".
How do I fix this?
Help.
Thanks,
Raymond
-
Well, you have to use a monospace font, not sans or serif. Try Courier New in your field.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|