Funny, I've always done it the other way around . . . what I mean is that I 
define the procedure/function int the Type (actually, the class) and then 
do the <Ctrl><Shift><c> which not only creates the prototype of the 
procedure/function but also puts my cursor there.  I will admit that I have 
not used default parameter values extensively but I have found that using 
the order of development that I do allows me to copy and paste once I get 
to the prototype.

I have just done a bit of experimentation and I will concede that you are 
right in that the prototype is created with the default value included in 
the parameter list; however, a bit of further experimenting produced a 
rather interesting phenomena . . . when I followed _my_ preferred creation 
sequence, not only did the application compile correctly but it also made 
use of the default value _even_ though the value did not appear other than 
in the forward declaration.

If you would like, I can send you the little test app in a zip file or you 
could recreate it by creating a project with one form that has one edit 
field (edTextEdit).  Once that is done, add a procedure (TestProc) to the 
private are of the form defined as follows:
procedure TestProc( s : String  = 'Default Value');

Once you have done that, do the <CTRL><SHIFT><c> to have the procedure 
created for you and add the following line as the only change to the 
prototype procedure:
   edTestEdit.Text :=  'TestProc was called with [' + s + ']';

Now, double click on the OnCreate event field of the form and add the 
following line to that procedure:
   TestProc;

Finally compile and run the test app . . . voila!  The app compiles and 
executes and the default value is used!

Could it be that, perhaps your coding practices which have likely carried 
over from VB, may be in conflict with Delphi's expected codeing practices?

At 7/29/2005 06:50 PM -0400, you wrote:
>It defines the method in the Type
>without the default param then when you try and compile it gives an error.
>In other words:
>
>procedure TSomeType.MyMethod(s: String = 'test);
>begin
>end;
>
>generates this in the type:
>
>private
>   procedure MyMethod(s: String);
>end;
>
>Most of our code uses default params, so I end up copying then pressing
>Ctrl-Alt-Up to take me to the Type definition and pasting.

Respectfully,

Ralph D. Wilson II                                 Web 
Site:  <http:thewizardsguild.com>
Systems 
Analyst                                   Email: 
<[EMAIL PROTECTED]>
San Antonio, TX 78259                       Alt Email:   <[EMAIL PROTECTED]>
H: (210) 497-2643
M: (210) 387-7744

"Any sufficiently advanced technology is indistinguishable from 
magic."  A.C.Clark 

__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to