我看楼主的最想解决的问题是想传一个二维数组的问题, 又不想用PString数组: 那么就用下面这个方法吧(直接拷贝运行):
unit u1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
XYJY1: array[1..4, 1..1] of string
= (('PX'),
('4'),
('3'),
(''));
ZFXX: array[1..4, 1..2] of string
= (('ES', 'ED'),
('3', '4'),
('0', '0'),
('preEnd', 'end'));
SWLL: array[1..4, 1..10] of string
= (('Z', 'Q', 'AC', 'VA', 'VM', 'HS', 'ZS', 'QS', 'AS', 'VS'),
('3', '4', '5', '6', '7', '8', '109', '110', '111', '112'),
('0', '0', '0', '0', '0', '0', '0', '0', '0', '0'),
('', '', '', '', '', '', '', '', '', ''));
type
TArrays = array of array of string;
procedure Disop(s: TArrays);
var
i, j: integer;
begin
for i := 0 to High(s) do
for j := 0 to High(s[0]) do
ShowMessage(s[i, j]);
// ....做各种动作
// ....做各种动作
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i, j: integer;
TempArrs: TArrays;
procedure GiveTempArrsVals(APStr: PString
FirHigh, SecHigh: Integer);
var
i: Integer;
i2, i3: Integer;
begin
SetLength(TempArrs, FirHigh);
for i := 0 to FirHigh - 1 do
setLength(TempArrs, SecHigh);
i := 1;
i2 := 0;
i3 := 0;
while (i <= FirHigh * SecHigh) do
begin
TempArrs[i2, i3] := APStr^;
Inc(APStr);
Inc(i);
Inc(i3);
if i3 mod SecHigh = 0 then
begin
Inc(i2);
i3 := 0;
end;
end;
end;
begin
GiveTempArrsVals(PString(@ZFXX), High(ZFXX), High(ZFXX[1]));
Disop(TempArrs);
GiveTempArrsVals(@XYJY1, High(XYJY1), High(XYJY1[1]));
Disop(TempArrs);
GiveTempArrsVals(@SWLL, High(SWLL), High(SWLL[1]));
Disop(TempArrs);
end;
end.
1. 注意动态数组的下标从0开始.
2. 肯定不用overload40个方法了.