ComponentCollection.CreateVariable Method

This method creates a new variable in the open component file. You can only use it to create Text, Number, Date, and True/False variables. (Other variable types cannot be created using this method.) Also, if a variable with the same name already exists in the component file, nothing will happen. You can also use the CreateComponent method, which allows you to create many other types of variables and components.

This method was introduced with the release of HotDocs 6.1.

Syntax

void CreateVariable ( string variableName, HotDocs.HDVARTYPE varType, string Prompt )

Parameters Description
variableName The name of the variable to create.
varType The type of variable to create. This value can be:
  • HD_TEXTTYPE
  • HD_NUMBERTYPE
  • HD_DATETYPE
  • HD_TRUEFALSETYPE
prompt [optional] The prompt for the newly created variable.

Example

The following Visual C# example creates a new component file and creates nine Text variables in it.

public class ExampleCode
{
    static void Main()
    {
        HotDocs.ComponentCollection ccl = new HotDocs.ComponentCollection();
         
        ccl.Create(@"C:\temp\Createdfile.cmp");
         
        for (int i = 1; i < 10; i++)
            ccl.CreateVariable("Variable " + i.ToString(), HotDocs.HDVARTYPE.HD_TEXTTYPE,Prompt for Variable " + i.ToString());
    }
}