This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ChiknNuggets's profile picture

splitting a string by length and words

Started by ChiknNuggets, 14 July 2012 - 02:23 AM
ChiknNuggets #1
Posted 14 July 2012 - 04:23 AM
well i got blurb{"Blurb1 blah blah blah blah blah","Blurb1 blah blah blah blah blah") and so on and each blurb cant be more then 26 characters per line(there is only 2 lines), i did manage to split it at char 26 but then the words might be cut in half, so my question is whats code would i use to make it so only 26 chars(at max) per line and if it cuts middle of a word it puts that whole word onto next line?
kazagistar #2
Posted 14 July 2012 - 05:09 AM
I did a search for split on the forums and found this: http://www.computercraft.info/forums2/index.php?/topic/2194-luaquestion-parsing-user-input-into-three-parts/page__p__16317__hl__split__fromsearch__1#entry16317

Now, you just reassemble, by adding word by word with spaces, until you would go over 26.
ChiknNuggets #3
Posted 14 July 2012 - 06:12 AM
yea i had a split function that i was using and i was thinking about something like this, but i guess there isnt an easier method, ill just do it this way then