AddVariable method

The AddVariable method adds a variable and its value to an object, such as a batch, document, page, or field. You can use this method when you need to pass values to a custom action. For example, your organization might introduce a new security regulation that requires a new field for identification on certain page types.

Syntax

VBScript
oDCO.AddVariable (strName as String, newValue as Variant) as Boolean
C#
bool m_oDCO.AddVariable (string strName, object newValue)

Arguments

strName
The variable name.
newValue
The value of the variable.

Returns

Returns true if successful; returns false if unsuccessful.

Applies to

All objects.

Examples

VBScript
This example adds the Company variable with a value of IBM to the page object.
Dim page
Call objField.AddVariable ("Company", IBM)
factor = objField.Variable("Company")
C#
This example adds the variable Company and the value IBM to page TM000001 in the runtime batch.
TDCOLib.IDCO m_oChild = m_oDCO.FindChild("TM000001");
if (m_oChild != null
)
{
m_oChild.AddVariable("Company", "IBM");
}
The resulting XML code is shown in the following example:
<?xml-stylesheet type="text/xsl" href="..\..\dco.xsl"?>
<B id="20100096.001">
	<V n="TYPE">APT</V>
	<V n="STATUS">0</V>
	<D id="20100096.001.01">
		<V n="TYPE">Invoice</V>
		<V n="STATUS">0</V>
		<P id="TM000001">
			<V n="TYPE">Main_Page</V>
			<V n="STATUS">0</V>
			<V n="Company">IBM</V>