一个Double型数组需要以实参形式传入一个函数,该函数的形参应该如何定义?
我是这样做的:
x: array[1..10] of double;
function abc(y: pdouble):extended:stdcall;
var
  i:integer;
  total:doubel;
begin
……
  total:=0;
  for i:=1 to 10 do
    total:=total+y[i];     <-编译出错
end;
编译出错,说Array type required.该怎么做才不会出错?

解决方案 »

  1.   

    更正一下: total:double;
    上面是手误。
      

  2.   

    你是不是想把x:array [1..10] of double;传入到函数里面啊?如果是那么就这样做:
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
        x :array [1..10] of double;
      public
        { Public declarations }
        function abc(x :PDouble):extended;stdcall;
      end;var
      Form1: TForm1;implementation{$R *.DFM}
    function TForm1.abc(x :PDouble):Extended;stdcall;
    begin
      ShowMessage('&acute;&laquo;&micro;&Yacute;&sup3;&Eacute;&sup1;&brvbar;!');
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      abc(@x);
    end;end.
      

  3.   

    Type
    Pdouble=arrary[1..10 of double;
    //定义pdouble类型,为一个含有10个元素的Double数组
    x: array[1..10] of double;
    function abc(y:pdouble):extended:stdcall;
    var
      i:integer;
      total:double;
    begin
    ……
      total:=0;
      for i:=1 to 10 do
        total:=total+y[i];     <-编译出错
    end;
      

  4.   

    to Linux2001(我想买手提电脑啊!) 
    好像不行啊!
      

  5.   

    to pilicat(delphi迷) 
    你的函数虽然可以编译通过,但是在函数调用的时候会出现类型不匹配的问题啊!实参是Pointer型的,而形参是PDouble型的。
    调用方法:abc(@x);