delphi - Passing parameter value to Function or Procedure with random order -


is there way in delphi pass parameter value function or procedure random order, don't have make sure order right.

example:

procedure insertemp(id: integer;name: string;gender: string); begin   //content end 

then use procedure this:

insertemp(1,'zemmy','male'); 

but if @ time change function parameter order this:

procedure insertemp(id: integer;nickname:string;name: string;gender: string); begin   //content end 

i have make position correction function following:

insertemp(1,'jim','zemmy','male'); 

can pass parameter value without correcting order? maybe way this:

insertemp(gender = 'male',nickname = 'jim',id = 1,name = 'zemmy'); 

thank help.

having 2 or more parameters of same type, called procedure cannot determine meaning.

i think answer can mix of whosrdaddy's comment lu rd's answer.

using overloading record constructor, can obtain smart solution.

type   temployee = record     id: integer;     nickname,     name,     gender: string;     constructor create(const aid: integer; const anickname, aname, agender: string); overload;     constructor create(const aid: integer; const aname, agender: string); overload; end;  procedure insertemp(const aemployee: temployee); begin   //content end;  constructor temployee.create(const aid: integer; const anickname, aname, agender: string); begin   id := aid;   nickname := anickname   name := aname;   gender := agender; end;  constructor temployee.create(const aid: integer; const aname, agender: string); begin   create(aid, '', aname, agender); end; 

var   myemployee: temployee;  begin   myemployee := temployee.create(1, 'zemmy', 'male');   insertemp(myemployee);   . . .   myemployee := temployee.create(1, 'jim', 'zemmy', 'male');   insertemp(myemployee); end.    

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -