Thread

Index > Scribe > Truncating strings in Print(..)
Author/Date Truncating strings in Print(..)
Scott
30/06/2019 9:51pm
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.
fret
01/07/2019 8:27am
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");


This
The second arg will limit the output to a fixed length.
Reply