怎样在过程中传递数组。(50分)

  • 主题发起人 主题发起人 细文
  • 开始时间 开始时间

细文

Unregistered / Unconfirmed
GUEST, unregistred user!

procedure AB(W:REAL;TAS:array OF array OF REAL);[?][?]
var
fj,fj1:string;
fk:boolean;
BEGIN
//对数组AB处理
end;
procedure TForm1.Button1Click(Sender: TObject);
var
w:real;
p:integer;
TAS:array OF array of REAL;
BEGIN
SETLENGTH(TAS,2,2);
W:=10;
TAS[0,0]:=2.1;
TAS[1,0]:=2.7;
AB(W,TAS);[?][?]
end;
end.
 
你直接传递就可以了
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
TForm1 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
temarray: W:REAL;TAS:array OF array OF REAL;
end;

procedure AB(W:REAL;TAS:array OF array OF REAL);
var
fj,fj1:string;
fk:boolean;
BEGIN
//对数组AB处理
end;
procedure TForm1.Button1Click(Sender: TObject);
var
w:real;
p:integer;
TAS:array OF array of REAL;
BEGIN
SETLENGTH(TAS,2,2);
W:=10;
TAS[0,0]:=2.1;
TAS[1,0]:=2.7;
AB(W,TAS);[?][?]
end;
end.
 
给你个例子:
FArr:array[0..100] of int;
procedure ChangeArr(var IArr:array of int);
begin
end;
Call:
ChangeArr(Farr);
 
type
TTAS: array of array of real;

procedure AB(W:REAL;TAS: TTAS);
var
fj,fj1:string;
fk:boolean;
BEGIN
//对数组AB处理
end;
procedure TForm1.Button1Click(Sender: TObject);
var
w:real;
p:integer;
TAS:TTAS;
BEGIN
SETLENGTH(TAS,2,2);
W:=10;
TAS[0,0]:=2.1;
TAS[1,0]:=2.7;
AB(W,TAS);
end;
end.
 
大侠:
过程AB(一个计算过程,返回原数组)在一个Unit2上,我想做成一个DLL。能帮忙吧。
 
请明确说明 过程AB(一个计算过程,返回原数组)在一个Unit2上[:)]
 
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TTAS=array of array of real;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
w:real;
p:integer;
TAS,S:TTAS;
T1,T2:REAL;
BEGIN
SETLENGTH(TAS,2,2);
W:=10;
TAS[0,0]:=2.1;
TAS[1,0]:=2.7;
S:=AB(W,TAS);[?][?]
T1:=S[0,1];
T2:=S[1,1];
end;
end.

unit Unit2;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
end;
type
TTAS=array of array of real;
var
Form2: TForm2;

implementation

{$R *.DFM}
FUNCTION AB(W:REAL;TAS:TTAS):TTAS;[?][?]
var
fj,fj1:string;
fk:boolean;
BEGIN
// 对数组TAS处理
.....
.....
RESUIT:=TAS;
end;
end.
将Unit2做成一个DLL。
 
新建一个dll工程,把函数ab写在里面并export出来,编译为dll后就可以在其它程序中调用了.
 
我不知数组(TAS)怎样可传递?
 
你可以声明一个类
type
TAS = array of array of string
这样就可以当一个参数传递了。
 
后退
顶部