HotDocs.Server.Value Class

A Value is the most basic building block of a HotDocs Answer. This is where individual pieces of data, such as text strings, dates, and numbers, are stored. Because HotDocs allows variables to be placed in repeated dialogs, each Answer may contain one or more Values.

In addition to the data (text, number, date, or other information) stored in the value property, each Value contains four 0-based repeat indexes to indicate the position of the Value within the HotDocs Answer. Any unused indexes should be set to -1 . For example, if a variable is not repeated, its Answer would contain only one Value with the following four repeat indexes:

-1, -1, -1, -1

For a repeated or nested variable, the indexes must indicate the position of the Value in relation to all other Values that make up the Answer. The following table shows the repeat indexes for a simple repeated variable that contains the names of the first three Presidents of the United States:

value RepeatIndex1 RepeatIndex2 RepeatIndex3 RepeatIndex4
George Washington 0 -1 -1 -1
John Adams 1 -1 -1 -1
Thomas Jefferson 2 -1 -1 -1

For a more complex example, review the next table, which lists the children of each President named in the previous table. A single Answer would contain all 12 Values. For each Value, the first index corresponds to the child's parent (siblings share the same first index), and the second index is the child's birth order. Because this example contains answers nested only two levels deep, the last two indexes are -1, which indicates that they are unused:

value RepeatIndex1 RepeatIndex2 RepeatIndex3 RepeatIndex4
John Parke Custis 0 0 -1 -1
Martha Custis 0 1 -1 -1
Abigail Amelia Adams 1 0 -1 -1
John Quincy Adams 1 1 -1 -1
Susanna Adams 1 2 -1 -1
Charles Adams 1 3 -1 -1
Thomas Boylston Adams 1 4 -1 -1
Martha Washington Jefferson 2 0 -1 -1
Jane Randolph Jefferson 2 1 -1 -1
Mary Wayles Jefferson 2 2 -1 -1
Lucy Elizabeth Jefferson I 2 3 -1 -1
Lucy Elizabeth Jefferson II 2 4 -1 -1

Namespace: HotDocs.Server
Assembly: HotDocs.Server in HotDocs.Server.dll

This class implements the following interfaces:

  • IDisposable: The class can be disposed.

Methods

Method Description
Value (Constructor) This constructor initializes a new instance of the Value class. For example, if you want to add a new piece of data to an existing HotDocs Answer, you could create a Value object, add the new data to the object, and then add the Value to the Answer.
Dispose This method is an implementation of the IDisposable.Dispose method that releases unmanaged resources held by an instance of the Value class.

Properties

Property Description
Answer [Read/Write] This property specifies the Answer object to which the Value belongs. (Each Answer object contains one or more Value objects, but each Value belongs to only one Answer.)
RepeatIndex1 [Read/Write] This property specifies the first repeat index for the Value. For non-repeated variables, this index is -1.
RepeatIndex2 [Read/Write] This property specifies the second repeat index for the Value. For non-repeated variables, this index is -1.
RepeatIndex3 [Read/Write] This property specifies the third repeat index for the Value. For non-repeated variables, this index is -1.
RepeatIndex4 [Read/Write] This property specifies the fourth repeat index for the Value. For non-repeated variables, this index is -1.
value [Read/Write] This property specifies the "value" of the Value. In other words, this would be the actual string of text, number, or Boolean value that a user entered for an Answer at the specified repeat indexes. The type of object returned corresponds to the type of data stored in the value. For example, a Number variable would return a number object and a Text variable would return a string. Multiple Choice variables, on the other hand, may return either a string or an array of strings depending on whether or not the variable allows multiple selections.

Example

This example opens an existing answer file and iterates through its Answers. The name of each Answer, and the value of each Value, is written to the console.

public class ExampleCode
{
    static void Main()
    {
        // Create an AnswerCollection and populate it with an existing answer file.
        HotDocs.Server.AnswerCollection ac = new HotDocs.Server.AnswerCollection();
        ac.Open(@"c:\temp\JohnDoe.anx");
         
        // Iterate through each Answer.
        foreach (HotDocs.Server.Answer ans in ac)
        {
            System.Console.WriteLine(ans.Name);
            // Iterate through each Answer's Values.
            foreach (HotDocs.Server.Value val in ans)
            {
                System.Console.Write(" " +
                    val.RepeatIndex1.ToString() + "," +
                    val.RepeatIndex2.ToString() + "," +
                    val.RepeatIndex3.ToString() + "," +
                    val.RepeatIndex4.ToString() + ": ");
                 
                if (val.value.GetType().IsArray)
                {
                    // This means the value is an array, such as a "select all that apply" Multiple Choice value.
                    System.Object[] valArray = (System.Object[]) val.value;
                     
                    for (int i = 0; i < valArray.GetLength(0); i++)
                    {
                        System.Console.Write(valArray[i].ToString());
                        if (i < (valArray.GetLength(0) - 1))
                            System.Console.Write("|");
                        else
                            System.Console.WriteLine();
                    }
                }
                else
                    System.Console.WriteLine(val.value.ToString());
            }
        }
        ac.Dispose();
    }
}