Page 1 of 1

an error I just can't crack

PostPosted: June 28th, 2007, 4:45 pm
by MrNotToSmartGuy
I am getting the following error.

"Types of actual and formal var parameters must be identical" I was wondering if someone would be able to comment on the error and help me out a bit more. I just can't seem to get this thing right.

MrNotTooSmartGuy

PostPosted: June 28th, 2007, 4:53 pm
by Johnny_Bit
simple yet rather hard to find.

let's say you have something like that:
Code: Select all

procedure surprise( var X: cardinal )

and then try something like:
Code: Select all

var
  Y: integer;
begin
  surprise( Y );
end;

you'll get that error. you know why? in this example Y isn't cardinal.

what I did? hardcore types?

PostPosted: June 28th, 2007, 5:18 pm
by Kambiz
In addition to what Johnny_Bit said, in the above example, calling surprise function with a constant parameter causes the same problem. It's because the parameter needs to be passed as reference and should be variable.

PostPosted: June 28th, 2007, 8:00 pm
by MrNotToSmartGuy
Thanks guys for the help. The error was that it should have been passed by reference. It works now. Thanks