Spiting a String after a certain number of characters

Hi all,

I have a text attribute called 'description' which can hold 2000 characters. I need to add this 'description' to a PDF but there is a restriction of only showing 30 characters per line.

How to I split the 'description' to a new line every 30 characters whilst ensuring that the split doesn't happen in the middle of a word?

Thanks for any help!

Asha

Hi Asha,

Did you tried to write out the steps it takes to achieve this, do this without thinking about how to do this in OutSystems. Just describe in words that you understand what you think needs to be done.

Then next try to think on how to implement those steps in OutSystems. If you then get stuck share your work on the forum, for someone to help you again.

Regards,

Daniel

Hi Asha,

Please find oml and find SplitChar screen.

i have made one sample for you. this is a mobile app you can achive this in web or rective also.

Hope this will help you/.

Regards

Rahul Sahu

Solution

Nice Rahul

I did this for traditional web: 

Pretty much the same without the substring just to show how it works underneath


Btw @Rahul, yours does split the words down the middle, not on spaces. Just a heads up.


Good luck Asha

Solution


Sharing an alternate solution just for fun, though I think Mariano Picco's solution is the ideal one =)

Mine checks the 30th and 31st character to see if its alphabets, because if its in the middle of a word the two characters are alphabets. 

https://caulibeam.outsystemscloud.com/TextSplitter/