Partilhar via


ExpansionFunction.GetArgument(Int32) Method

Definition

Gets the value of the specified argument, resolving any fields referenced in the argument. In the substitution, "$$" is replaced with "$" and any floating '$' signs are left unchanged, for example "$US 23.45" is returned as is. Only if the two dollar signs enclose a string of letters or digits is this considered a field name (e.g. "$foo123$"). If the field is not found then the unresolved string "$foo" is returned.

public:
 System::String ^ GetArgument(int index);
public:
 Platform::String ^ GetArgument(int index);
std::wstring GetArgument(int index);
public string GetArgument (int index);
member this.GetArgument : int -> string
Public Function GetArgument (index As Integer) As String

Parameters

index
Int32

[in] The position in the arguments array to get.

Returns

The specified argument if it exists, otherwise null.

Remarks

This helper method is called from your implementation of the GetCurrentValue method to retrieve the value of the specified argument. If you want to access an argument by name, call the GetFieldValue method with the name of the argument.

An argument can be either an explicit value or a variable. A variable is surrounded by dollar signs ("$myvar$") and represents an expression in the code snippet template that has a value or another expansion function assigned to it. If an argument is not surrounded by dollar signs or is surrounded by single or double quotes, then the argument is taken literally as the value for that argument.

For example, given the function declaration (as seen in a code snippet template file) <function>MyFunction($expr1$,"value1",'value2',value3)</function>, expr1 is a variable that contains a value to be returned, value1, value2, and value3 are all literal values that are returned as is for those arguments.

This method calls the GetFieldValue method to obtain the value of a variable. If the variable cannot be resolved to a value, the name of the variable is surrounded by dollar signs and returned as the value.

Applies to