|Index > Scribe > Truncating strings in Print(..)|
|Author/Date||Truncating strings in Print(..)|
|I'm trying to truncate a string that I'm printing. I tried using Split with max_split set to the length of the string, but that didn't seem to work. How can this be done?
Is there anyway that I could limit the length of the text being sent to the Growl application. I'm often getting extremely long links being displayed in the notification which are very distracting and slow to display.
|Split will turn the string into an array based on the separator characters you supply, which is the wrong function for what you want. Your looking for 'Sub'. Which stands for sub-string:
string obj.Sub(start[, end]);
Or in context:
MyStr = "This is my test string"; JustThis = MyStr.Sub(0, 4); Print(JustThis + "\n");
The second arg will limit the output to a fixed length.