Apologies if this has been covered before, but I can’t find anything which I can understand enough to make work…
All I want to do is shorten titles to manageable sizes. I can do this easily enough if I don’t care about word boundaries.
$Name = $String.substr("0,49")
works well, but it’s ugly. I’d like to do the equivalent to pick up the first 10 words, like
$Name = $String.words("0,9")
to pick up the first 10 words. I can’t see anything like that.
Looking around I can see some possibilities, e.g.:
$MyList = $String.split("\W"); $ShortName = $MyList.at(0) + " " + $MyList.at (1) + ....
but that is going to get very tedious quickly.
I can’t see an operator / action to take the first x items of list, which means I need some sort of iteration.
I think I’m supposed to use $MyList.each(), but I can’t get it to work, and I’m not sure I’m understanding what’s going on. The atbref is helpful, of course, but I can’t get it work in these circumstances.
a) is there an easier way which I’m just not seeing; or
b) is it possible to explain how to use .each() to do what I want?