我想写一个函数,返回一个数组,怎么声明啊?我写成
function getstring(i:integer):array of string ;
编译的时候提示 identifier excepted but 'ARRAY' found;
这是怎么回事啊?

解决方案 »

  1.   

    确实,改用tstringlist较好,给你个例子。
     function StringToSTringList(s,split: string):TStringList;
    var
      v_temp: string;
      v_len: integer;
    begin
      Result := TStringList.Create;
      v_temp := s;
      while v_temp <> '' do
      begin
        v_len := POS(split, v_temp);
        if v_len = 0 then
        begin
          Result.Add(v_temp);
          v_temp := '';
        end
        else
        begin
          Result.Add(Copy(v_temp, 0, v_len - 1));
          v_temp := Copy(v_temp, v_len + 1, Length(v_temp) - v_len);
        end;
      end;
    end;
      

  2.   

    可以这样
    procedure getstring(i:integer; var OutArray :array of string);
      

  3.   

    返回成TStringDynArray,还要引用Types单元