best way to add a new line
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
best way to add a new line
Is there an easy way to write a new line in a field/container? I'd like to add a new line after the existing contents.
I can do, put return&"xyz" after fld "abc" but if I build up a field from scratch this way, I get a blank first line.
Thanks.
-Chuck
I can do, put return&"xyz" after fld "abc" but if I build up a field from scratch this way, I get a blank first line.
Thanks.
-Chuck
Re: best way to add a new line
Hi Chuck,
what about:
Been using this for years!
Best
Klaus
what about:
Code: Select all
...
put "xyz" into tNewLine
if fld "abc" <> EMPTY then
put CR before tNewLine
end if
put tNewLine after fld "abc"
...
Best
Klaus
Re: best way to add a new line
Thanks. I thought there might be some neat way to do it without the conditional... Nice to know at least that part of my code isn't inelegant.
Re: best way to add a new line
I'm really sorry, that the only solution is not more erm... glamorous!
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: best way to add a new line
I don't know about glamorous, but if you are really averse to conditionals, you could always:
This does not care how many lines, or any at all, are in the field.
Craig Newman
Code: Select all
put "xyz" into line the number of lines of fld "yourField" + 1 of fld "yourField"
Craig Newman
Re: best way to add a new line
Hi Craig,
believe me, that is much more glamorous than my solution!
Best
Klaus
believe me, that is much more glamorous than my solution!
Best
Klaus
Re: best way to add a new line
Yeah, that's clever. So the number of lines returns 0 if the field is empty. Neat.
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: best way to add a new line
Glamorous, and now clever. Well, this is old, old magic.
Craig
Craig