Function retornando mais de um Result
Existe alguma forma de fazer uma Function retornar mais que um valor?
Alguém sabe como fazê-lo?
Alguém sabe como fazê-lo?
Kenji_rh
Curtidas 0
Respostas
Beppe
03/05/2004
Pode fazer a função retornar um record contendo os campos q precisar, ou fazer via parâmetros out ou var.
GOSTEI 0
Motta
03/05/2004
defina um tipo
type Tmeutipo = record
numero integer;
letra string;
end;
a funtion retorn este tipo
function minhafunction : Tmeutipo;
function .....minhafunction : Tmeutipo;
begin
Result.numero := 1;
Result.letra := ´a´;
end;
type Tmeutipo = record
numero integer;
letra string;
end;
a funtion retorn este tipo
function minhafunction : Tmeutipo;
function .....minhafunction : Tmeutipo;
begin
Result.numero := 1;
Result.letra := ´a´;
end;
GOSTEI 0
Tinorj
03/05/2004
:idea: :D :) :( :o :? 8) :lol: :P :roll: :wink: :idea:
:!:
[]´s
:!:
function TForm1.RetornaArray: Variant; var VarLocal: Array of Variant; Tam: Integer; begin Tam := Length(VarLocal); SetLength(VarLocal, Tam + 1); VarLocal[Tam] := 1; Tam := Length(VarLocal); SetLength(VarLocal, Tam + 1); VarLocal[Tam] := ´Nome´; Tam := Length(VarLocal); SetLength(VarLocal, Tam + 1); VarLocal[Tam] := now; Result := VarLocal; end; procedure TForm1.Button1Click(Sender: TObject); var teste: Array of Variant; begin teste := RetornaArray; ShowMessage(IntToStr(teste[0]) + teste[1] + DateToStr(teste[3])); end;
[]´s
GOSTEI 0