Hola:
Estoy probando lo que me habeis dicho:
Código Delphi
[-]
Unit datos;
interface
uses sysutils;
type
TVector = Array of array of double;
var
L_72_F_32_1_1V: array [0..3,0..4] of double =
(
( 0,2,3,4,1 ),
( 1,3,4,5,3 ),
( 2,3,3,4,8 ),
( 3,2,3,4,9 )
);
L_72_F_32_1_2V: array [0..2,0..4] of double =
(
( 1,2,3,4,1 ),
( 2,3,4,5,3 ),
( 2,3,3,4,8 )
);
L_72_F_32_1_3V: array [0..3,0..4] of double =
(
( 1,2,3,4,1 ),
( 2,3,4,5,3 ),
( 2,3,3,4,8 ),
( 2,2,3,4,9 )
);
FUNCTION proc_L_72_F_32(ns:integer; CC:String):TVector;
implementation
FUNCTION proc_L_72_F_32(ns:integer; CC:String): TVector;
begin
if (nS = 1) AND (cC = '1V') then
Result := L_72_F_32_1_1V
else if (nS = 1) AND (cC = '2V') then
Result := L_72_F_32_1_2V
else if (nS = 1) AND (cC = '3V') then
Result := L_72_F_32_1_3V
end if
end;
end.
Pero al compilar me dice -lineas marcada en rojo de proc_L_72_F_32- que los tipos Array - TVector son incompatible .
He modificado la función de la siguiente forma:
Código Delphi
[-]
FUNCTION proc_L_72_F_32(ns:integer; CC:String): TVector;
var
v: TVector;
i, h: integer;
begin
if (nS = 1) AND (cC = '1V') then
begin
Setlength(v, High(L_72_F_32_1_1V)+1, High(L_72_F_32_1_1V[0])+1);
for i:= High(v) downto Low(v) do
begin
for h:= High(v[i]) downto Low(v[i]) do
v[i,h]:= L_72_F_32_1_1V[i,h];
end;
end
else if (nS = 1) AND (cC = '2V') then
Setlength(v, High(L_72_F_32_1_2V)+1, High(L_72_F_32_1_2V[0])+1);
for i:= High(v) downto Low(v) do
begin
for h:= High(v[i]) downto Low(v[i]) do
v[i,h]:= L_72_F_32_1_2V[i,h];
end;
else if (nS = 1) AND (cC = '3V') then
....
end if
result:= v;
end;
Con lo que en cada caso hay que "recorrer" el array para asignarselo al array dinámico.
¿Alguna forma de mejorar esto, o de realizar una asiganción "directa"?