Hi Frank,

You are passing a table to editor:ReplaceSel(); I did a little test:

editor:ReplaceSel ({'one','two'})

and the selection disappears. So you would have to make your table
into a string using table.concat(buf,'\n').

BTW, removing stuff using your method should work:

for i = 1,#t do
        if t[i] == '' then
                table.remove(t,i)
        end
end

t = {'one','','two','three'}

for i,v in pairs(t) do print(i,v) end

gives us what one would expect.

steve d.



On 8/3/07, Frank Wunderlich <[EMAIL PROTECTED]> wrote:
> Hi
> i want to write a funktion to remove empty lines in a selection
> this is my code:
>
> function removeEmptyLines()
>    local buf={}
>    local sel = editor:GetSelText()
>    buf = lines(sel)
>    for i=table.getn(buf),1,-1 do
>      _ALERT(i.." - "..buf[i])
>      if buf[i]=='' then
>        table.remove(buf,i)
>      end
>    end
>    editor:ReplaceSel(buf)
> end
>
> it seems that the last entry of the table contains the full seletion, al
> others the exact line.
>
> the following selection:
> 123
>
> 456
>
> 789
>
> gives me in the output pane:
> 5 - 123
>
> 456
>
> 789
> 4 -
> 3 - 456
> 2 -
> 1 - 123
>
> if the remove is called, the complete selection is deleted.
>
> what have i done wrong?
>
> regards Frank
> _______________________________________________
> Scite-interest mailing list
> [email protected]
> http://mailman.lyra.org/mailman/listinfo/scite-interest
>
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to