Easy to Create, Easy to Change - Easy to use!


Converting LineFeed in text to <br> for use in CMS.


Started by Henk
Search
You will need to Sign In to be able to add or comment on the forum!

Converting LineFeed in text to <br> for use in CMS.

I have a challenge. I import text into a DE system for editing in Memo and then I am re-exporting it for use in a CMS system.

The problem is that the Memo field use traditional ASCII(10) ASCII(13) for Line Feed, but the CMS expect <br>

Any Suggestion?

Written by Henk 29/07/13 at 14:00:39 Dataease [{8}]FIVE

Re:Converting LineFeed in text to <br> for use in CMS.

Yes, this is easy. We used the same approach in our first Email client (pre. HTML editor).

If the CMS had been designed in DG3 you would simply use a filter |linebreaksbr ex. [{mymemo|linebreaksbr}] would automatically convert old style line feed into <br>.

However, your challenge is not much harder ;-) 

In DE8 we have added a chr() function to both search for and insert ascii values into fields/memos etc. and a function to replace occourences in a Memo - MemoReplace().

So you simply need to run the function  MemoReplace(MyMemo,Chr(13),"<br>") and all the old style Linefeeds will be changed into the HTML version <br>.

You can replace either ASCII 10 or 13 but not both as it will give you two <br>s. It doesn't matter that the chr(10) or chr(13) is left in the text as HTML just ignore it anyway.

If you are a perfectionist and can't live with leaving it behind simply do this instead:

MemoReplace(MyMemo,concat(chr(10),chr(13)),"<br>") and it will replace them both with one <br>. I don't recommend it as it will only work if the order is 10,13 and not 13,10. A lot of modern texts only use one of them too....

Written by DataEase Tech Support 29/07/13 at 14:03:03 Dataease [{8}]FIVE