delphi函数返回数组的问题,delphi函数返回数组的问题。大家帮帮我哈。
函数在这:unitreadini;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Con...
函数在这:
unit readini;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,IniFiles,StrUtils;
type
InfoArray= array of array of string;
var
myinifile:Tinifile;
function readinifile(str:string):InfoArray;
implementation
function readinifile():InfoArray;
begin
Setlength(result,2,2);
result[0,0]:='aaa';
result[0,1]:='bbb';
result[1,0]:='ccc';
result[1,1]:='ddd';
end;
end.
现在我在另一个类里调用它
unit mainctrl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,readini,StrUtils,installfile;
var
procedure ctrlinstall(tmpstr:string);
implementation
procedure ctrlinstall(tmpstr:string);
var
i: integer;
TmpArray:array of array of string;
begin
TmpArray := readini.readinifile(); //这句话就出错,这是为什么啊
for i:= 1 to High(TmpArray) do
begin
。。。。
end;
end;
end.
出错显示 incompatible types,明明都是array,为什么不匹配呢。 展开
unit readini;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,IniFiles,StrUtils;
type
InfoArray= array of array of string;
var
myinifile:Tinifile;
function readinifile(str:string):InfoArray;
implementation
function readinifile():InfoArray;
begin
Setlength(result,2,2);
result[0,0]:='aaa';
result[0,1]:='bbb';
result[1,0]:='ccc';
result[1,1]:='ddd';
end;
end.
现在我在另一个类里调用它
unit mainctrl;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,readini,StrUtils,installfile;
var
procedure ctrlinstall(tmpstr:string);
implementation
procedure ctrlinstall(tmpstr:string);
var
i: integer;
TmpArray:array of array of string;
begin
TmpArray := readini.readinifile(); //这句话就出错,这是为什么啊
for i:= 1 to High(TmpArray) do
begin
。。。。
end;
end;
end.
出错显示 incompatible types,明明都是array,为什么不匹配呢。 展开
3个回答
展开全部
function readinifile():InfoArray;
begin
Setlength(result,2,2);
result[0,0]:='aaa';
result[0,1]:='bbb';
result[1,0]:='ccc';
result[1,1]:='ddd';
end;
end.
函数没有返回值
加一句:
return result;
不过主要原因可能是:
type
InfoArray= array of array of string;
var
myinifile:Tinifile;
function readinifile(str:string):InfoArray;
InfoArray的定义位置错误,把他放到var下,即:
var
myinifile:Tinifile;
InfoArray= array of array of string;
function readinifile(str:string):InfoArray;
begin
Setlength(result,2,2);
result[0,0]:='aaa';
result[0,1]:='bbb';
result[1,0]:='ccc';
result[1,1]:='ddd';
end;
end.
函数没有返回值
加一句:
return result;
不过主要原因可能是:
type
InfoArray= array of array of string;
var
myinifile:Tinifile;
function readinifile(str:string):InfoArray;
InfoArray的定义位置错误,把他放到var下,即:
var
myinifile:Tinifile;
InfoArray= array of array of string;
function readinifile(str:string):InfoArray;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询