Fórum Função multiparametros #277735
18/04/2005
0
Bem, trabalhei com clipper muitos alguns anos e nele tinha um comando muito util chamado STORE, que servia para atribuir um valor(númerico ou string) a varias variaveis ao mesmo tempo.
Ex: store 98 to a,b,c,d,e,i,j
ou seja, assim como a=98, os outros também seriam
store ´MARIA DA SILVA´ to a,b,c,d,e,i,j
Estou querendo criar uma função em delphi onde eu passase o primeiro parametro como o Texto ou Valor e os outros parametros as variaveis que eu vo atribuir: store(´MARIA DA SILVA´,a,b,c,d).
alguém sabe como???
Ricardoif
Curtir tópico
+ 0Posts
18/04/2005
Beppe
procedure Store(const V: String; A: array of Pointer); overload; var I: Integer; begin for I := Low(A) to High(A) do String(P^) := S; end; procedure Store(const V: Integer; A: array of Pointer); overload; var I: Integer; begin for I := Low(A) to High(A) do Integer(P^) := S; end;
Na chamada, passe ponteiros para as variáveis:
Store(98, [@a, @b, @c, @d, @e, @i, @j]); Store(´MARIA DA SILVA´, [@a, @b, @c, @d]);
PS: Não testei, se não funcionar, posta aqui para corrigirmos o erro.
Gostei + 0
22/04/2005
Ricardoif
procedure TForm1.Store(const V: String; A: array of Pointer);
var
i: Integer;
p: ^String;
begin
for I := Low(A) to High(A) do
String(P^) := V;
end;
procedure TForm1.Store(const V: Integer; A: array of Pointer);
var
i: Integer;
p: ^Integer;
begin
for I := Low(A) to High(A) do
Integer(P^) := v;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
a,b,c: string;
e,f,g: integer;
begin
store(´Maria MADALENA´,[@a,@b,@c]);
Label1.caption:=a;
msg(a);
msg(b);
msg(c);
store(1550,[@e,@f,@g]);
msg(e);
msg(f);
msg(g);
end;
Gostei + 0
22/04/2005
Marcelo Saviski
Gostei + 0
22/04/2005
Beppe
Exatamente isso! :oops: :wink:
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)