multiLines Field

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: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

multiLines Field

Post by robm80 » Mon Jul 21, 2014 11:56 pm

In a multiline field 3 lines are selected. What's wrong with this script? No errormessages.

Code: Select all

repeat with i=1 to 19
if the selected of line i of fld "spec"is true then
put line i of fld "spec" into tVar
end if
end repeat
put tVar

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: multiLines Field

Post by Simon » Tue Jul 22, 2014 1:07 am

Hi Rob,
The simple form is just to set the script of the field to

Code: Select all

on mouseUp
   put the selectedText
end mouseUp
If you did have a reason for the repeat just say.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

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

Re: multiLines Field

Post by dunbarx » Tue Jul 22, 2014 3:28 am

Hi.

Are you sure you did not want the "hilitedLines" property? This gives all hilited lines in a list field. What do you think? Are hilited lines also selected?

Not that you cannot do this by script, but in your handler you do not collect the lines of interest in your construction. You do display them, but rather quickly. Do you see why? Step through the handler and watch. What is the last thing sent to msg?

Another hint. instead of running from 1 to 19 (unless you have a specific reason to do so) think about this:

Code: Select all

repeat with
i = 1 to the number of lines of fld "spec'"
Can you see (at least in general) that this is more robust than the original?

Craig Newman

robm80
Posts: 161
Joined: Sat May 03, 2014 7:15 am

Re: multiLines Field

Post by robm80 » Tue Jul 22, 2014 4:15 am

Thank you both Craig & Simon,
Both answers give a result:

put the selectedText of fls "spec" answers with the written lines, f.i.
John
Walter
Jim

put the hilitedLines of fld "spec" answers with the numbers of the lines, f.i.
1,3,6

Both are very useful.
Rob

Post Reply