Noob question how to process an unknown string to break it up nicely.

hi all,
first post, I’m just getting my head around vuo so forgive me if this is very obvious and my sample patch is wrong. I would appreciate all feedback :)

I’m trying to make a comp that will take a string of various lengths up to 144 characters, and then it will break it down so that it displays shorter messages bigger and longer messages smaller, for best readability while keeping the text all within a set area of my window. (red box in attached comp)

So far I have been able to get an ok solution I split the incoming string with character counting to make it one of two sizes and position new lines . But the problem is this patch will split a word in the middle / leave me with just one character on a new line. I know the “split text” node will break the incoming string into a list of words, but I can’ t figure out the “process list” logic to step through that list and then either append the next item to a string on line 1 or if line one is now too long to create a new line…

Also I don’t fully get when I need a “fire periodically” / “fire on start” or when a node just seems to run itself so please correct me here to make this comp as efficient as possible :)

secondly if the string has a link to a video in it, is there any way to display that video in the comp?

thanks…

text splitter better.vuo (15.3 KB)

Not such a noob question in my opinion. I ran some tests but could not find yet a solution neither.

That will be way easier when that feature requests get implemented : Provide option to automatically wrap text images/layers

And for the others questions, Generally, for most nodes you only need a Fire on start.
But for the nodes that must move or use time inputs you need time or screen refresh frequency of course.

I guess you probably wonder when yo use Fire On Start or Fire Periodically because right now when you LIVECODE the node does not reload itself when you change a parameter (as QC does because it has PULL and Vuo right now only PUSH). But that is changing it the next update and nodes will auto reload. If already you want to see changes automatically when you live code you’ll have to relaunch the node after changes (cmd-click ont a port for example) or you use a Fire Periodically but be sure to disconnect it when you’re done live coding because that will slow down your composition.
Fire Periodically is still useful if you want your text strings to change every minute for example ;)

Check the manual or some examples that’s in there.

And if the string has a video url in it yes you can play it. Click on the Play Movie node in the node gallery below in the node info there are links to some compositions that use that node.

However I’m not sure if Vuo can already download and play videos from the web, images yes, videos the only time I tried it did not work but that really can be because of me doing it wrong.

Here’s a composition that splits text into words and joins it back together into lines of less than or equal to 60 characters. The idea is to loop through the words and keep appending them into an accumulated text, until you find that appending one more would pass the character limit, or you reach the end of the list.

I would second @Bodysoulspirit’s advice that you check out the manual if you haven’t already, particularly the sections on events in “3. The basics” and “4. How events and data travel through a composition”. Also the video tutorials.  

SplitWordsJoinLines.vuo (8.91 KB)

Hi Jaymie,
Thank you so much for this, I have watched some tutorials and read the manual, slowly getting it… One question about your patch is there a way to add test for the max characters for each individual element and trim and split if necessary? e.g. right now if someone were to accidentally enter a string with 57 characters (when limit set to 50) and no space it will not be trimmed and so expand beyond the width I’m trying to restrict the content to… does that make sense? image and patch attached.

SplitWordsJoinLines g.vuo (16.6 KB)

Amazing Jaymie ! Hey @grahamis if you want the text size to be adjusted automatically when the window gets resized use something like this ;) (joined composition).

SplitWordsJoinLines 1.1.vuo (10.9 KB)

hi @Bodysoulspirit thanks, but I’m using this as an image generator and so I can’t do anything with the window and I can’t predict if it will get short, or long text or correctly written… So I want to be able to adjust the characters to split on dynamically so that I re-size shorter text to be bigger. However whenever I try to use a “share value” as an input to the “Is Greater than” that controls the character split it cuts off some of the text, even if I don’t do anything else, is there something about the flow of execution in this I need to manage? I also need that test so that if any of the sections of text in the list are as a single entry longer than my character limit they get broken up into two items in the list… can you help with that?

@grahamis you can still use image width in Image Generator mode.

I tried to adapt Jaymie’s composition to adapt the amount of words per line depending on the image width (within a range) + make font size depending on it too.

Try perhaps to play with it to achieve your goal, sorry I did not really understand your last comment. Hope that helps though.  

SplitWordsJoinLines 1.4.vuo (12.4 KB)

1 Like

right now if someone were to accidentally enter a string with 57 characters (when limit set to 50) and no space it will not be trimmed and so expand beyond the width I’m trying to restrict the content to

I would maybe run the text through a preliminary Process List loop to chop up the words, before sending it through the Build List loop. The attached composition makes some progress in that direction. It only breaks up a very long word correctly if the word is the first in its line, but maybe that gives you a starting point.

whenever I try to use a “share value” as an input to the “Is Greater than” that controls the character split it cuts off some of the text, even if I don’t do anything else, is there something about the flow of execution in this I need to manage?

I’m not sure what you mean. Could you post the composition? — and please post it on a new question / discussion, since sticking to one topic per page makes it easier to for other people to find answers if they have similar questions in the future.

SplitWordsJoinLines 2017-03-29.vuo (19.3 KB)