HI! Thanks in advance.
I wanna make comething like this:

Procedure GETDATA( VAR	 x	: TCaption	)	;
Begin
     ....
	x	:= '1'	;
     ...
End	;


    ...
    ...

        a( SOMEString )     ;
	a( SOMETEDit.Text )	;
	a( SOMETLabel.Caption )	;

end;

HOw can I solve it? Thanks!!!

Edited 5 Years Ago by Ezzaral: Added code tags. Please use them to format any code that you post.

HI pritaeas, thanks in advance.

I make some small real code in Delphi

---
procedure P( S : TCaption);
begin
S := '1' ;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
P(Label1.Caption) ;
P(Edit1.Text)
end;

If a write VAR params doesn't compile. If don't returns nthing as pascal define


I don't wanna have a 1 function for every need,l like this


procedure P( Var S : String);
begin
S := '1' ;
end;

procedure P( Var S : TEdit);
begin
S.Text := '1' ;
end;

procedure P( Var S : TLabel);
begin
S.Caption := '1' ;
end;


Thanks!!!!

This should work:

procedure P(var S: string);
begin
  S := '1' ;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  P(Label1.Caption) ;
  P(Edit1.Text)
end;

AS I told you on first date: E2197 Constant object cannot be passed as var paramet

:( its a delphi mistake

Does this work ?

function P: string;
begin
  Result := '1' ;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := P;
  Edit1.Text := P;
end;
This article has been dead for over six months. Start a new discussion instead.