кажется у меня похожая проблема, но у меня все это не работает
я пытался решить проблему так:
http://www.delphisources.ru/forum/sh...ad.php?t=14362
затем решил сделать иначе:
Код:
type
ArrayOfConst = array of TVarRec;
function _const (anArgs: array of const) : ArrayOfConst;
var
I : WORD;
Index : WORD;
Length : WORD;
begin
Length := 0;
if ( High (anArgs) >= 0 ) then
Length := Length + High (anArgs) - Low (anArgs) +1;
if ( Length > 0 ) then
begin
SetLength (Result,Length);
Index := 0;
for I := Low (anArgs) to High (anArgs) do
begin
Result [Index] := anArgs [i];
Inc (Index);
end;
end;
end;
function ParamToArrayOfConst (const aValue: TVarRec) : ArrayOfConst;
begin
Result := _const([]);
with aValue do
try
case VType of
vtPointer: Pointer (Result) := VPointer;
end;
except
Result := _const([]);
end;
end;
function arrays (anArgs: array of const) : String;
var
I : WORD;
A : ArrayOfConst;
begin
Result := '';
for I := Low (anArgs) to High (anArgs) do
begin
A := ParamToArrayOfConst (anArgs [i]);
if Assigned (A) then
begin
if ( I <= Low (anArgs) ) then
Result := arrays (A)
else
Result := Format ('%s, %s',[ Result, arrays (A) ]);
end
else if ( I <= Low (anArgs) ) then
Result := ParamToStr (anArgs [i])
else
Result := Format ('%s, %s',[ Result, ParamToStr (anArgs [i]) ]);
end;
Result := Format ('[%s]',[Result]);
end;
caption := arrays ([ 'a', _const(['test1']), 'b', _const(['test2','test3']), 'c', TForm, Pointer(TForm){, Pointer(form1)}, NIL, self, _const(['test4','test5', 2.718281828459045, _const(['A','B','C']), 'test6' ]), 'hello', pi ]);
Все отлично работает, но только до тех пор, пока я не передам в массив какой-то другой указатель. Как мне правильно отличить типы переменных, на которые указывают указатели?
если указатель Pointer(TForm) еще как-то обрабатывается Except-ом, то Pointer(form1) сносит башню
что делать?