I know this is a old thread, but I have been trying to implement a similar script to solve an issue and am running into problems.
I have a significant amount of visual logic running, and as a result, this script doesn't work for (in part because the context of the text field I need to wrap is dynamically set via visual logic). I have tried to replicate the script, or my own variant of it in visual logic, but have encountered other issues, such as using the logic block to find a " " character to split lines doesn't return correctly if the start point if after the last space character. Also, the concatenate block does not allow me to add a CR/LF code into the text.
Is there an easier way to constrain a text box to two lines high? Or does someone have a good example of a visual logic approach to this?
In terms of pseudo code, I see it like this:
If text.width < box.width, exit
If text.width < box.wdth * 1.1, autosqueeze = true 'allows a small amount of squeeze on one line
If text.width > box.width * 1.1, find split point at first line length or midpoint depending on length, insert a CR to make it two lines
Any help appreciated!
Thanks, Dave
#XPression