Truncate Text Based On Available Space?

Monte Goulding monte at sweattechnologies.com
Wed Jun 12 22:57:22 EDT 2013


On 13/06/2013, at 12:47 PM, J. Landman Gay wrote:

> I did this ages ago, like back in MC. I used a real field, but now that I know better I'd use the templatefield instead. It's ugly, but since you can only measure text width from a field, you have to loop. The pseudocode is something like:
> 
> store the original text somewhere for reference later
> put it into a field
> repeat until the formattedwidth of the text is <= the column:
>  delete last char of the field
>  put "..." into last char of the field
> end repeat
> 
> Even with a "real" field it was still pretty fast. Probably would be faster with the templatefield. The "..." isn't three periods, it needs to be the real elipsis character so that the "last" character includes all three visual dots.

Cool... wouldn't it be nice if there was a field property to get it to do that automatically....

--
M E R Goulding 
Software development services
Bespoke application development for vertical markets

mergExt - There's an external for that!




More information about the use-livecode mailing list