PDA

View Full Version : Help with some String splicing


rctshine
03-20-2007, 05:14 PM
I have this code:

titlelength = String.Length(tblTag.Title);
if titlelength > 17 then
trimamount = titlelength - 14;
tblTag.Title = String.TrimRight(tblTag.Title, trimamount);
tblTag.Title = tblTag.Title.."..."
end

My goal is to get any name longer than 17 characters to fit in the given box. I'm trying to get it to rename things like, for instance, this Evanescence song:

Bring Me to Life (demo) by Evanescence
I would like to be:
Bring Me to Li...by Evanescence

My code doesn't seem to be doing it properly, and I'm not sure what I did wrong. Any ideas?

rctshine
03-20-2007, 05:30 PM
Edit: I think I figured it out.

RizlaUK
03-20-2007, 05:41 PM
use String.Mid to trim the string


LongString = Input.GetText("Input1");
StringLenth = String.Length(LongString);
if StringLenth > 18 then--adjust the number you want to trim
LeftString = String.Mid(LongString, 1, 9);--adjust the number you want to trim
RightString = String.Mid(LongString, StringLenth-9, StringLenth);--adjust the number you want to trim
ShortString = LeftString.."..."..RightString
Input.SetText("Input2", ShortString);
end

attachment shows it working


EDIT:

Edit: I think I figured it out.

Nice Job :yes