Tim_S Posted March 18, 2016 Report Share Posted March 18, 2016 I was working on a user interface and needed to put text in a button. I realized I needed to word wrap the text and couldn't find a VI that already does that. The generic algorithm seems to combine words together and put in line feeds when the length is exceeded. Based on that I put together the attached (please pardon the dust). Then I started wondering if there was a better way. Any thoughts? Tim Format for word wrap.vi Quote Link to comment
bmoyer Posted March 18, 2016 Report Share Posted March 18, 2016 This is the one that I commonly use. Word Wrapping.vi Word Wrapping (Entire Column).vi 1 Quote Link to comment
Tim_S Posted March 18, 2016 Author Report Share Posted March 18, 2016 This is the one that I commonly use. I like that implementation. I took the first paragraph of text from NI's LabVIEW webpage (115 words) and put it in to a comparison of 10,000 iterations on a fresh load of LabVIEW. bmoyer's algorithm: 15,028 msec Tim_S's algorithm: 15,365 msec Then I went tried again with the text "I'm a test": bmoyer's algorithm: 4,688 msec Tim_S's algorithm: 617 msec I added more text from the same webpage for 284 words and wound up with: bmoyer's algorithm: 28,519 msec Tim_S's algorithm: 38,095 msec Quote Link to comment
ensegre Posted March 20, 2016 Report Share Posted March 20, 2016 (edited) As per text formatting utilities, gnu has fmt. Additionally, there is par. Perhaps you may consider wrapping them. AFAIR, they simply don't cope with multibyte characters (at best they treat them as independent bytes), but alas, neither LV does really. But right, they count characters, they have no notion of font metrics, which is what could be asked for in an UI. Edited March 20, 2016 by ensegre Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.