Page 1 of 1

best way to add a new line

Posted: Thu Jan 22, 2015 5:19 pm
by cwkalish
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

Re: best way to add a new line

Posted: Thu Jan 22, 2015 5:25 pm
by Klaus
Hi Chuck,

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"
...
Been using this for years! :D


Best

Klaus

Re: best way to add a new line

Posted: Thu Jan 22, 2015 6:34 pm
by cwkalish
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

Posted: Thu Jan 22, 2015 10:54 pm
by Klaus
I'm really sorry, that the only solution is not more erm... glamorous! :D

Re: best way to add a new line

Posted: Fri Jan 23, 2015 2:56 pm
by dunbarx
I don't know about glamorous, but if you are really averse to conditionals, you could always:

Code: Select all

put "xyz" into line the number of lines of fld "yourField" + 1 of fld "yourField"
This does not care how many lines, or any at all, are in the field.

Craig Newman

Re: best way to add a new line

Posted: Fri Jan 23, 2015 3:04 pm
by Klaus
Hi Craig,

believe me, that is much more glamorous than my solution! :D


Best

Klaus

Re: best way to add a new line

Posted: Sat Jan 24, 2015 10:12 pm
by mattmaier
Yeah, that's clever. So the number of lines returns 0 if the field is empty. Neat.

Re: best way to add a new line

Posted: Sun Jan 25, 2015 2:44 am
by dunbarx
Glamorous, and now clever. Well, this is old, old magic.

Craig