p-95
14 years agoOccasional Contributor
Overloading methods
Hi, Is there an opiton of overloading methods? Another quastion, is there an opiton to set default values for paremeters in methods? Thanks Ziv
Not really. That is, you can't define several functions with the same name but different parameter sets - neither in VBScript, nor in JScript, nor in DelphiScript.
Is there an opiton of overloading methods?
function Main()Search VBScript overloading and JScript overloading for more examples.
{
Log.Message(Add10(5));
Log.Message(Add10("7"));
}
function Add10(Value)
{
switch (aqObject.GetVarType(Value))
{
case varInteger: return Value + 10;
case varOleStr: return parseInt(Value) + 10;
default: throw "Invalid parameter type";
}
}
In DelphiScript - yes, see Default Values of Routine Parameters.
Another quastion, is there an opiton to set default values for paremeters in methods?