Prune

From UBot Studio
Jump to: navigation, search

This function is an Advanced Text function in the UBot Extended Library.

This function is an elegant version of truncate. Its features make sure the pruned string does not exceed the original length. It is best to avoid half chopped words when pruning.


Text to prune: The text being pruned.

Location: Position where sentence should stop.


Can be used with the Find Index function to quickly find the position of a word within the sentence for proper pruning.


Example

In this example, we want everything after the word "Start" to be pruned. First, we find the index of the first word after the word "Start", which is "small"

set(#indextext,$find index("Make an investment into yourself. Start small with a few hours of training and watch as your potential unfolds.","small"),"Global")

After the index is found, the variable the index is assigned to is placed in the Prune function in place of "Location".

alert($prune("Make an investment into yourself. Start small with a few hours of training and watch as your potential unfolds.",#indextext))


The resulting text is shown below:


Prunetxt.jpg

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox