代码之家  ›  专栏  ›  技术社区  ›  Ryan

Delphi有没有得到每个循环的A?

  •  23
  • Ryan  · 技术社区  · 16 年前

    我读过Delphi应该在Delphi9的每个循环中得到一个。这项功能是否曾经融入到语言中?我的Delphi2009 IDE似乎无法识别for-each语法。以下是我的代码:

      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;
    
    2 回复  |  直到 16 年前
        1
  •  44
  •   da-soft    16 年前
    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; 
    
        2
  •  26
  •   John Thomas    16 年前

    对。

    但它是 在…中

    尝试

    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;