On Fri, 11 Jul 2003, ZINTEL Gerhard wrote:

> hello list members,
>
> could anyone of you give me a hint how to assign a value to an untyped
> variable parameter of a procedure. E.G. in the following procedure:
>
> procedure test(var value);
> var r : real;
> begin
>   r := 1.0;
>   value := real;      // does not work
> end;
>
> which type to be used for a type cast (that is not allowed for the left
> side) or how to use an address operator to manage it?

One way would be:

procedure test(var value);

Type
  PReal = ^real;

var
  r : real;

begin
  r := 1.0;
  PReal(@value)^ := r;
end;

Another way would be:

procedure test(var value);

Type
  PReal = ^real;

var
  P : PReal;
  r : real;

begin
  P:[EMAIL PROTECTED];
  r := 1.0;
  P^ := r;
end;

It may be more suitable if you need more than one operation or when R is
an arraytype.

Michael.






_______________________________________________
fpc-pascal maillist  -  [EMAIL PROTECTED]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to