Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-07

how to assign a value to an untyped variable

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ZINTEL Gerhard

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?

any help would be welcome
gerhard

-------------------------------
Gerhard Zintel
Faurecia Abgastechnik GmbH
Abt.: EGA
Tel.: +49 911 7610171
Fax.: +49 911 7610350
e-mail: GZintel-AT-Stadeln.Faurecia.com

Evergray
to ZINTEL Gerhard

Hello Gerhard,

Friday, July 11, 2003, 3:18:58 PM, you wrote:

ZG> hello list members,

ZG> could anyone of you give me a hint how to assign a value to an untyped ZG> variable parameter of a procedure. E.G. in the following procedure:

ZG> procedure test(var value);
ZG> var r : real;
ZG> begin
ZG>   r := 1.0;
ZG>   value := real;        // does not work
      value := r;           // didn't ã mean so?
ZG> end;

ZG> which type to be used for a type cast (that is not allowed for the left ZG> side) or how to use an address operator to manage it?

     real(value) := r

ZG> any help would be welcome
ZG> gerhard

ZG> -------------------------------
ZG> Gerhard Zintel
ZG> Faurecia Abgastechnik GmbH
ZG> Abt.: EGA
ZG> Tel.: +49 911 7610171
ZG> Fax.: +49 911 7610350
ZG> e-mail: GZintel-AT-Stadeln.Faurecia.com

WBR, Evergray

Words mean nothing...
Evergray
to ZINTEL Gerhard: could anyone of you give me a hint how to assign a value to an untyped variable parameter…

Hello all,

Friday, July 11, 2003, 3:18:58 PM, you wrote:

ZG> hello list members,
...
ZG> which type to be used for a type cast (that is not allowed for the left ZG> side) or how to use an address operator to manage it? at least in my fpc 1.0.6 typecasts for the left side are allowed, value := r; // error
real(value) := r; // works ! ;-)

WBR, Evergray

Words mean nothing...
Michael Van Canneyt
to ZINTEL Gerhard: could anyone of you give me a hint how to assign a value to an untyped variable parameter…
ZINTEL Gerhard wrote 14 lines
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
  ;
  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.