Friday, 15 January 2010

pass by reference - Delphi: Types of Actual and Formal Parameters Must Be Identical -



pass by reference - Delphi: Types of Actual and Formal Parameters Must Be Identical -

there lot of questions title; however, none address issue. actually trying pass reference, yet receiving e2033: types of actual , formal var parameters must indentical error when trying compile code. trying pass 3 (3) variables, each integer, 2 reference (var) , other not.

i not understand issue code, below. have included declaration, definition, , call.

declaration of routine:

private updatedevicestatus(var areturncount, anotfoundcount: integer; anumofdevices: integer);

i have tried not condense declaration of arguments , declared var first two, explicitly' however, did not work.

question 1: error because mixing reference , value (if remember, correctly, languages not permit this)?

definition of routine:

procedure tfrmreturnmetertomfg.updatedevicestatus(var areturncount, anotfoundcount: integer; anumofdevices : integer); begin // end;

really, code in body of routine trivial regard problem , not impact problem (at to the lowest degree shouldn't cause in case).

the phone call routine:

the next contained within routine's body:

// local variables: var returncount, notfoundcount, numofdevices: integer; begin // happens each of these values (they incremented) updatedevicestatus([returncount], [notfoundcount], numofdevices); end;

then receive error.

question 2: result of syntax when calling routine (attempting pass arguments)?

edit

so, may wondering (you beingness more experienced delphi programmer), "where did lark pick [ , ] bit? here's resource consulting (and see why looked @ wrong thing in comments, below): consulted resource.

i guess brackets problem. code works me:

program project12; {$apptype console} type tfrmreturnmetertomfg = class private procedure updatedevicestatus(var areturncount, anotfoundcount: integer; anumofdevices : integer); end; procedure tfrmreturnmetertomfg.updatedevicestatus(var areturncount, anotfoundcount: integer; anumofdevices : integer); begin // end; var thing : tfrmreturnmetertomfg; returncount, notfoundcount, numofdevices: integer; begin returncount := 4; notfoundcount := 2; numofdevices := 42; thing := tfrmreturnmetertomfg.create; thing.updatedevicestatus( returncount, notfoundcount, numofdevices); thing.free; end.

adding brackets around argument changes meaning of code completely, mean something. in particular case, adding brackets instruct compiler pass

updatedevicestatus( [ returncount ], // array or set of integer (with 1 element) [ notfoundcount ], // same 1 time again here numofdevices // integer );

this different.

delphi pass-by-reference

No comments:

Post a Comment