Page 1 of 1
Inserting seperate lines into text field
Posted: Mon Feb 14, 2011 10:26 am
by Wynn
I am stuck on a rather simple problem that i cant get my head around, how do i make a button insert data into a text field, but make it start a new line for each new piece of data entered? Normally the program would replace the old data with the new instead of making them both share the same text box. Now, me being a complete newbie at this, i dont even know how to start going around this... Help would be appreciated!
Re: Inserting seperate lines into text field
Posted: Mon Feb 14, 2011 11:48 am
by Mark
Wynn,
Code: Select all
put cr & mySomeVar after fld "Some Field"
Make sure to read the user manual.
Kind regards,
Mark
Re: Inserting seperate lines into text field
Posted: Mon Feb 14, 2011 3:25 pm
by dunbarx
Mark's idea is perfectly correct, you can write a return BEFORE the new data you wish to append, So that if you have:
AAA
BBB
in your field, if you put return & "CCC" into that field, the return will force the data to be written into the next line:
AAA
BBB
CCC
Just as if you typed the return and then the "CCC". I only mention this so that I can ask you to consider the other way to do it:
put the number of lines of fld "yourField" + 1 into entryLine
put yourData into line entryLine of fld "yourField"
You use a property of the field to ascertain the target line number. I frequently add data to adjacent linked fields, some of which may have a different number of lines. I need to know that any new data I add will always be below the field with the most number of lines, and this is a way to do it.
Re: Inserting seperate lines into text field
Posted: Mon Feb 14, 2011 5:54 pm
by BvG
Uhm.. I can't see any advantage of first getting the number of lines, in fact for large datasets it'd be slowing down a bit? Is it so you don't need to use a return? Just curious about why you do it that way. If i need a super clean way of adding lines, I do this:
Code: Select all
if the number of lines in field "target" > 0 then
put return & "new line" after field "target"
else
put "new line" into field "target"
end if
in your field, if you put return & "CCC" into that field, the return will force the data to be written into the next line:
you probably meant to say:
in your field, if you put return & "CCC" after that field, the return will force the data to be written into the next line:
Re: Inserting seperate lines into text field
Posted: Mon Feb 14, 2011 6:17 pm
by dunbarx
Right on about the "after".
I have several apps where adjacent fields contain various data, and there is a single "title" line of data that corresponds to perhaps several lines of data in the adjacent fields. If I add a new data set, I need to know the extent of the longest multi-line fields in order to properly set the line where the new "title" line will go. Then I will put each "record" into, not after, that "entryline". I agree that in a single field, return & data will always find the next line.
My point was that by using a function (not property, as I said. Too fast, too fast...) one can get considerable additional control. The number of lines in one field determines the entry line in another.
Re: Inserting seperate lines into text field
Posted: Tue Feb 15, 2011 4:32 am
by jsburnett
Another way is ...
put newData into line (the number of lines of field "Old Data" + 1) of field "Old data"
Thanks.