Book a Demo

Author Topic: How to add method parameters in correct order?  (Read 3621 times)

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
How to add method parameters in correct order?
« on: May 28, 2007, 06:49:25 am »
Hi,

I've added several parameters to a method via automation. The trouble is that the order of these parameters in EA isn't the same as I used when into EA.

For example:
I have 3 parameters: par1, par2, par3
and I want to add them to myMethod:

parameters = myMethod.getParameters();
parameters.AddNew(par1.getName(),par1.getType());
par1.update();
parameters.refresh();

parameters.AddNew(par2.getName(),par2.getType());
par2.update();
parameters.refresh();

parameters.AddNew(par3.getName(),par3.getType());
par3.update();
parameters.refresh();

Although the parameters were added in the par1,par2,par3 order, EA seem to ignore this order and I can see those parameters in a rather random order.

Could anybody, please, tell me how to fix it?

PS: ...and still all the parameters are visible only when displaying the method properties. In Project Browser I can only see the first parameter (the first parameter in the EA ordering...). I'm quite confused. :-[
« Last Edit: May 28, 2007, 06:51:05 am by chrvi »
Radek

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to add method parameters in correct order?
« Reply #1 on: May 28, 2007, 09:04:29 am »
Take a look at the Kind and Position properties of the Parameter class. You'll find these in the EA help and user guide.

I suspect (without any proof) that the sole parameter you see is what EA believes to be the return type. Otherwise it may simply be whichever parameter EA thinks is first in the list (in the absense of your explicitly setting the Position property).

Meanwhile, bring up the Tools | Options | Objects dialog, and confirm that the settings at the bottom of both columns of check boxes are what you want. I don't know if this will affect parameter display at all, but it is worth checking out.

David
No, you can't have it!

chrvi

  • EA User
  • **
  • Posts: 75
  • Karma: +0/-0
  • There are so many hidden features...
    • View Profile
Re: How to add method parameters in correct order?
« Reply #2 on: May 29, 2007, 04:12:15 am »
Aaah thanks a lot! :-)

By the way (if anybody was interrested), the parameters are numbered from zero (i.e. the position can be 0,1,2...)
Radek

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: How to add method parameters in correct order?
« Reply #3 on: May 29, 2007, 03:39:52 pm »
Thanks yourself,

This came full circle today when I noticed that an automation client was retrieving attributes in the order they were added to the model instead of the order they appear in the class.

I'd have stumbled over the base number of the sequence for sure.

David
No, you can't have it!