我已经读过Delphi应该为Delphi 9中的每个循环得到一个。这个功能是否已经成为该语言的一部分?我的Delphi 2009 IDE似乎无法识别每种语法。这是我的代码:
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;
答案 0 :(得分:45)
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;
答案 1 :(得分:26)
是
但 for..in
尝试
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;