procedure comeon(a: array of const);
begin
  showmessage(inttostr(high(a)));
end;procedure Sum (const A: array of integer);
var
  I: Integer;
begin
  showmessage(inttostr(high(a)));
end;procedure TForm1.btn1Click(Sender: TObject);
var
  List: array [1..10] of Integer;
  a: array of integer;
  X, I: Integer;
begin
  setlength(a, 10);
  for i := 0 to 9 do a[i] := i;
  comeon(); // 这里怎样填啊??slice和copy都不能,请教:0
end;

解决方案 »

  1.   

    Open array constructors allow you to construct arrays directly within function and procedure calls. They can be passed only as open array parameters or variant open array parameters.An open array constructor, like a set constructor, is a sequence of expressions separated by commas and enclosed in brackets. For example, given the declarationsvar I, J: Integer;
    procedure Add(A: array of Integer);you could call the Add procedure with the statementAdd([5, 7, I, I + J]);This is equivalent tovar Temp: array[0..3] of Integer;
     ...
    Temp[0] := 5;
    Temp[1] := 7;
    Temp[2] := I;
    Temp[3] := I + J;
    Add(Temp);Open array constructors can be passed only as value or const parameters. The expressions in a constructor must be assignment-compatible with the base type of the array parameter. In the case of a variant open array parameter, the expressions can be of different types.
      

  2.   

    array of const
    array of integer
    类型不同
      

  3.   


    procedure comeon(a: array of const);
    改成
    procedure comeon(a: array of integer);
    就行了
      

  4.   

    呵呵,我是在使用adoquery.insertrecord(array of const);的时候需要动态插入记录,
    var
      a: array of string;
    begin
      setlength(a, 10);
      insertrecord(); //这里不知道如何填:(
    end;
      

  5.   

    呵呵,我是在使用adoquery.insertrecord(array of const);的时候需要动态插入记录,
    var
      a: array of const; //<--这样试一下看看
    begin
      setlength(a, 10);
      insertrecord(); //这里不知道如何填:(
    end;
      

  6.   

    是啊,如何解决?const是常量:(