PtokaX forum

Development Section => Your Developing Problems => Topic started by: VidFamne on 06 June, 2004, 01:33:36

Title: Cut of Nick's
Post by: VidFamne on 06 June, 2004, 01:33:36
Here is a little code snippet ;
Code: [Select]
function Name(name)
local n = name
if strlen(n) > 18 then
n = strsub(n,1,15)
n = n.."..."
return n
to cut off very long Nick's, maybe to fit in,  in a column or whatever...
Just wonder if there is a smother way to do this.
Post by: NotRabidWombat on 06 June, 2004, 07:59:22
It's late, so I'm just going to throw out an idea without testing.

format("%"..width.."s", name);

It *should* behave like printf, allowing you to make nice columns. Only problem is you can't have the "...".

Post by: VidFamne on 06 June, 2004, 23:22:18
Doesn't ;
Code: [Select]
format("%"..width.."s", name); tell where the name begins?
E.g. 12 character from the begining, if width is 12 .
I'm not so familiar with function format.
Hmm, change my mind ;))
will do the job, to cut off the string.