Inserting seperate lines into text field
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Inserting seperate lines into text field
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
Wynn,
Make sure to read the user manual.
Kind regards,
Mark
Code: Select all
put cr & mySomeVar after fld "Some Field"
Kind regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Inserting seperate lines into text field
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.
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
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
you probably meant to say:in your field, if you put return & "CCC" into that field, the return will force the data to be written into the next line:
in your field, if you put return & "CCC" after that field, the return will force the data to be written into the next line:
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: Inserting seperate lines into text field
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.
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
Another way is ...
put newData into line (the number of lines of field "Old Data" + 1) of field "Old data"
Thanks.
put newData into line (the number of lines of field "Old Data" + 1) of field "Old data"
Thanks.