Ver Mensaje Individual
  #8  
Antiguo 03-11-2011
Avatar de javier7ar
javier7ar javier7ar is offline
Miembro
 
Registrado: abr 2006
Ubicación: Argentina
Posts: 124
Reputación: 21
javier7ar Va por buen camino
nop, no se puede.

En Delphi, la forma de asociar los parametros reales (los que estas pasando) a los parametros formales (los que estan declarados) es pocicional, es decir, el primer parametro que pasas lo asocia con el primer parametro declarado, el segundo con el segundo, y asi. Por eso no podes pasar un valor para el 3er parametro sin haber pasado un valor para los 2 primeros.

Otra cosa: los parametros que tienen un valor por defecto se declaran a la derecha, y si un parametro tiene un valor por defecto los siguientes (a la derecha) deben tener tambien un valor por defecto (esto es por la misma razon que te mencione arriba)

Te dejo lo que dice la ayuda de Dephi sobre Parametros con Valores por Defecto
Saludos

Cita:
Default parameters
You can specify default parameter values in a procedure or function heading. Default values are allowed only for typed const and value parameters. To provide a default value, end the parameter declaration with the = symbol followed by a constant expression that is assignment-compatible with the parameter’s type.
For example, given the declaration

Código Delphi [-]
procedure FillArray(A: array of Integer; Value: Integer = 0);

the following procedure calls are equivalent.

Código Delphi [-]
FillArray(MyArray);
FillArray(MyArray, 0);

A multiple-parameter declaration cannot specify a default value. Thus, while

Código Delphi [-]
function MyFunction(X: Real = 3.5; Y: Real = 3.5): Real;

is legal,

Código Delphi [-]
function MyFunction(X, Y: Real = 3.5): Real;   // syntax error

is not.
Parameters with default values must occur at the end of the parameter list. That is, all parameters following the first declared default value must also have default values. So the following declaration is illegal.

Código Delphi [-]
procedure MyProcedure(I: Integer = 1; S: string);   // syntax error

Default values specified in a procedural type override those specified in an actual routine. Thus, given the declarations

Código Delphi [-]
type TResizer = function(X: Real; Y: Real = 1.0): Real;

function Resizer(X: Real; Y: Real = 2.0): Real;
var
  F: TResizer;
  N: Real;

the statements

F := Resizer;

F(N);

result in the values (N, 1.0) being passed to Resizer.
Default parameters are limited to values that can be specified by a constant expression. Hence parameters of a dynamic-array, procedural, class, class-reference, or interface type can have no value other than nil as their default. Parameters of a record, variant, file, static-array, or object type cannot have default values at all.
For information about calling routines with default parameter values, see Calling procedures and functions.
Responder Con Cita