mitchell, 03.08.2007 19:18:
Frank Wunderlich wrote:
steve donovan, 03.08.2007 13:04:
On 8/3/07, Frank Wunderlich <[EMAIL PROTECTED]> wrote:
you make a forward-loop, this is no good idea when removing items from a
list (skipping next entry after deletion,maybe accessing item out of
list-bounds at the end). the loop should go backwards. and there i get
this strange behaviour.
is #t the same as table.getn(t)?

Yes, you are right about the order.

but how to get the decreasing loop, without this strange last item?

Frank

You could create another table and add elements that don't match to it.

local new = {}
for i = 1, #t do
  if t[i] ~= '' then table.insert(new, t[i]) end
end



this is not working for me

function removeEmptyLines()
  local buf={}
  local sel = editor:GetSelText()
  buf = lines(sel)
  local new = {}
  for i = 1, #buf do
    if buf[i] ~= '' then table.insert(new, buf[i]) end
  end
  editor:ReplaceSel(table.concat(new,"\n"))
end

selection: without lines
---------------------
123

456

789
---------------------

becomes
---------------------
123
456
123

456

789
---------------------

using SciTE Version 1.74 .49Ru (don't know if mozers changed anything)

regards Frank
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to