Argument.Handler

Introduced

v4.0

Description

Returns or sets the ArgumentHandler of the argument.

A null reference is returned when the argument has no handler. You may remove an argument handler by setting the handler property to a null reference.

You may also use a string to set an argument handler. The string must match the unique name of an argument handler. See siArgumentHandler for a complete list of the available argument handlers.

Warning: Calling this method flushes any existing value associated with the Argument, see Argument.Value.

Note: this method should not be confused with Command.Handler which returns the name of the script function that implements the command.

Examples

JScript Example

// JScript example demonstrating how you can
// find out about ArgumentHandlers associated 
// with the arguments of a Command
// Cleanup
RemoveCommand("CmdWithHandler");
// Command creation
var oCmd = CreateCommand("CmdWithHandler");
oCmd.Code = CmdImpl.toString(); // Embedded command
oCmd.Language = "JScript";
var oCmdArgs = oCmd.Arguments;
var noValue; 
oCmdArgs.AddWithHandler("myArgument", "Collection");
oCmdArgs.Add("myArgWithoutHandler", siArgumentInput, "defaultValue");
AddCommand(oCmd);
// display the arguments
for (i=0; i < oCmdArgs.Count; i++)
{
                var currentArg = oCmdArgs(i);
                var argHandler = currentArg.Handler;
                if (null != argHandler)
                {
                        LogMessage(currentArg.Name + " has the following handler: " + argHandler.Name );
                }
                else
                {
                        LogMessage(currentArg.Name + " does not have a handler.");
                }
}
// let's remove the argument handler
var oArgWithHandler = oCmdArgs("myArgument");
oArgWithHandler = noValue;
// Implementation of the custom command
function CmdImpl( collectionArg, basicArg )
{
}