I've read that Delphi was supposed to get a for each loop in Delphi 9. Did this functionality ever make it into the language? My Delphi 2009 IDE doesn't seem to recognize the for each syntax. Here's my code:
procedure ProcessDirectory(p_Directory, p_Output : string);
var
files : TStringList;
filePath : string;
begin
files := GetSubfiles(p_Directory);
try
for (filePath in files.Strings) do
begin
// do something
end;
finally
files.Free;
end;
end;
procedure ProcessDirectory(p_Directory, p_Output : string);
var
files : TStringList;
filePath : string;
begin
files := GetSubfiles(p_Directory);
try
for filePath in files do
begin
// do something
end;
finally
files.Free;
end;
end;
Yes.
But it is for..in
Try
var
s: string;
c: char;
begin
s:=' Delphi Rocks!';
for c in s do //<--- here is the interesting part
begin
Application.MainForm.Caption:=Application.MainForm.Caption+c;
Sleep(400); //delay a little to see how it works
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With