Hi all.
I am having a problem with tmemo in that if I delete one item in the loop below
the memo is stuffed afterwards. But in the second example memo is OK. Any tips??
Logically, memo count is adjusted after one item deleted but tval is inc'd for next.
Tval needs to be dec'd prior to next count (I think) but you cant do that!

  for tval := 0 to memo1.Lines.Count - 1 do
  begin
    with memo1.Lines do
    begin
      if (directoryexists(strings[tval])) then //its DEFINITELY a directory
        if not dirhasfile(strings[tval]) then delete(tval)
        else
          strings[tval] := IncludeTrailingBackSlash(strings[tval]) + '*.*';
    end;
  end;


This works:
  counter:integer;

  for tval := 0 to memo1.Lines.Count - 1 do
  begin
    with memo1.Lines do
    begin
      if (directoryexists(strings[tval])) then //its DEFINITELY a directory
        if not dirhasfile(strings[tval]) then counter:=tval
        else
          strings[tval] := IncludeTrailingBackSlash(strings[tval]) + '*.*';
    end;
  end;
memo1.lines.delete(counter); //FINE FOR ONE INSTANCE ONLY!

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to