Page 1 of 1

Using Delete Line with HilitedLine results

Posted: Fri Dec 01, 2006 11:19 pm
by rc
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

Posted: Sat Dec 02, 2006 11:29 am
by Klaus
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

Posted: Sat Dec 02, 2006 9:41 pm
by rc
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