How to line break/return with <br/> in LC

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

How to line break/return with <br/> in LC

Post by glenn9 »

I've put together a simple utility in LC which will export a tsv file so that it can then be imported into a flashcard application.

So far so good, I learnt yesterday evening how to successfully export a tsv from LC (with much sense of achievement as I put the GUI and code together in less than an hour!) and I was then able to successfully import the resulting file into the flashcard app... however, it only imports as long as there is only a single line of text, ie no line breaks or returns.

It seems that the flashcard app requires any line breaks to be identified with the '<br/>' code as below.

'Creating Line Breaks in Imported Decks: Anywhere that you would like to have a line break occur in the resulting deck, include this text '<br/>' in your CSV/TSV file'


I therefore tried to accommodate this with:

Code: Select all

on returninfield
   put "<br/>" & return after field 1
   -- omitting the '& return' doesn't help either!
end returninfield
However, the flashcard app says the resulting text is invalid and refuses to import it.

Not sure whether this is a LC issue in terms of the code that it uses for line breaks/returns or whether its the flashcard app's issue.

Superficially I'm thinking that it doesn't seem to like the code that LC is using for line break/return and was assuming that if I can replace the code that LC uses for line breaks/returns with <br/> then it will import!?

I was therefore wondering if it is therefore possible to replace the code LC is using for a line break/return with a <br/> instead?

Grateful for any thoughts/advice,

Regards,

Glenn
Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: How to line break/return with <br/> in LC

Post by Thierry »

glenn9 wrote: I was therefore wondering if it is therefore possible to replace the code
LC is using for a line break/return with a <br/> instead?
Hi Glenn,

This one is straightforward:

Code: Select all

replace cr with "<br/>" in variableWithYourText
Otherwise, I have no idea if this will resolve your main issue...

HTH,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to line break/return with <br/> in LC

Post by glenn9 »

Hi Thierry,

This has worked perfectly, thank you so much. Especially that I now understand after looking at your code why mine wasn't working!

Kind regards,

Glenn
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: How to line break/return with <br/> in LC

Post by dunbarx »

So was it the case that even when you explicitly wrote "<br/>" instead of return, you may have still had some returns in your text?

Thierry's offering is guaranteed to eliminate those, of course, but I am just wondering...

Craig
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: How to line break/return with <br/> in LC

Post by glenn9 »

I think so Craig, I guess I didn't have insight that I was inadvertently adding a 'CR' code (by pressing the 'return' key whilst I was in the field) each time I added the '<br/>' code initially!!

Regards,

Glenn
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to line break/return with <br/> in LC

Post by Klaus »

Hi Glenn,
I was therefore wondering if it is therefore possible to replace the code LC is using for a line break/return with a <br/> instead?
since we are dealing with LC, most of the time the first thought is the correct one and we can translate it almost 1:1 into LC!
See Thierrys script! :-)


Best

Klaus
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10509
Joined: Wed May 06, 2009 2:28 pm

Re: How to line break/return with <br/> in LC

Post by dunbarx »

What Klaus really meant was "since we are dealing with LC, the answer is YES"

Craig
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to line break/return with <br/> in LC

Post by Klaus »

Oh, did I? :-D
Post Reply