an error I just can't crack

Please discuss general Delphi programming topics here.

an error I just can't crack

Postby MrNotToSmartGuy » June 28th, 2007, 4:45 pm

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
MrNotToSmartGuy
Active Member
Active Member
 
Posts: 8
Joined: June 28th, 2007, 4:29 pm

Postby Johnny_Bit » June 28th, 2007, 4:53 pm

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?
Last edited by Johnny_Bit on June 29th, 2007, 7:08 am, edited 1 time in total.
Thou shalt write the code, not connect the bricks.
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » June 28th, 2007, 5:18 pm

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby MrNotToSmartGuy » June 28th, 2007, 8:00 pm

Thanks guys for the help. The error was that it should have been passed by reference. It works now. Thanks
MrNotToSmartGuy
Active Member
Active Member
 
Posts: 8
Joined: June 28th, 2007, 4:29 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron