## an error I just can't crack

Please discuss general Delphi programming topics here.

### an error I just can't crack

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

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

Posts: 455
Joined: June 15th, 2003, 9:56 am

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

Kambiz

Posts: 2426
Joined: March 7th, 2003, 7:10 pm

Thanks guys for the help. The error was that it should have been passed by reference. It works now. Thanks
MrNotToSmartGuy
Active Member

Posts: 8
Joined: June 28th, 2007, 4:29 pm