Using Delete Line with HilitedLine results

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
rc
Posts: 2
Joined: Thu Nov 30, 2006 8:40 am

Using Delete Line with HilitedLine results

Post by rc » Fri Dec 01, 2006 11:19 pm

I've got a scrolling text field (photosList) that accepts drag-n-drop filenames for photos. So far, the drag-n-drop code is working, and filenames are successfully added to the field.

If the user needs to remove one or more filenames from the list, I've added a button/script that puts the hilitedLine results into tLines. I then try to delete these lines with delete line tLines of field "photosList". This works great if only one line was selected, but it fails when tLines contains more than one line.

Any ideas on how to accomplish a multi-line delete from a scrolling text field? A different approach, perhaps?

thanks,

Robert

Klaus
Posts: 12195
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Post by Klaus » Sat Dec 02, 2006 11:29 am

Hi Robert,

if there are more than one line selected "the hilitedlines" return something like "1,4,5,7"!

So "delete line tLines of fld xyz" will of course not work.

You will have to use a repeat loop and start with the LAST item in tLines:

...
repeat with i = the number of items of tLines down to 1
## we have to start from the end!
delete line (item i of tLines) of fld xyz
end repeat
...

Hope that helps.


Regards

Klaus

rc
Posts: 2
Joined: Thu Nov 30, 2006 8:40 am

Post by rc » Sat Dec 02, 2006 9:41 pm

Hi Klaus,

Thanks for your help--that did the trick. And you were right, I needed to start with the last item in tLines, which often contained the noncontiguous multiline selection.

Thanks again,

Robert

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”