An Answer is the set of Values for a particular HotDocs variable. For example, the Answer for a non-repeated variable consists of a single piece of data (text string, number, date, or other information) stored in a single Value. The Answer for a repeated variable, however, consists of multiple Values—one for each time the variable is repeated.
There are several ways to iterate through the Values of an Answer. If you know the repeat indexes for the Value you want to retrieve, you can simply set the 0-based repeat indexes of the Answer to those indexes. Thus, if you want to retrieve the second Value of a simple repeated variable, you could set the Answer's repeat indexes to 1,-1,-1,-1 . (Unused indexes should be set to -1 .) Once these indexes are set, retrieving the Answer's Value will return the data stored in the Value with the specified repeat indexes.
ProgID: | HotDocs.Answer.11.0 HotDocs.Answer (version-independent) |
CLSID: | {4D509C2B-0223-47EB-95A5-CC8E98055F67} |
The following table shows the name and IID for each interface, as well as the version of HotDocs in which it was introduced. The primary interface and the main public interface exposed by this object is _Answer.
Name | IID | Added in |
_Answer | {DF34C5CA-1760-4262-9B56-24E3EDE60994} | Added in HotDocs 6.0 |
_AnswerEvents | {E485B97D-1BBF-4174-A97C-4B03D5EB33C2} | Added in HotDocs 6.0 |
The _AnswerEvents interface designates an event sink interface that an application must implement in order to receive event notifications from a HotDocs.Answer object.
Method | Description |
![]() |
This method adds an additional value to a particular Multiple Choice answer iteration. |
![]() |
This method does nothing. (It was deprecated in HotDocs 6.01.) |
![]() |
This method creates a new HotDocs answer. |
![]() |
This method returns the number of repeated values at a certain level of the repeat. |
![]() |
This method returns the repeat index information for the current value. |
![]() |
This method indicates if a particular option in a Multiple Choice variable is selected. |
![]() |
This method starts a recursive descent of the values for an answer. It visits each value for an answer and fires the Answer.OnValueFound event. In many cases, this saves you (the integrator) from iterating through combinations of repeat indices to find values in an answer tree. |
![]() |
This method sets the current value of the Answer object to the value at the specified repeat indexes. |
Property | Description |
![]() |
[Read-only] This property returns a reference to the Application object. |
![]() |
[Read-only] This property returns the name of the answer. This is a read-only property because the Name is set using the Answer.Create method and cannot be changed after the answer is created. |
![]() |
[Read-only] This property returns the number of repeated values at the current level. The difference between this property and the Answer.GetRepeatCount method is that this property returns the repeat count for the current level only. The GetRepeatCount method returns the repeat count for a level specified by a set of repeat indexes given in the method call. |
![]() |
[Read-only] This property returns the type of the Answer object. |
![]() |
[Read/Write] This is a Boolean property that determines whether an answer is marked as "Unanswered." If so, Unanswered clears the value at that repeat level. |
![]() |
[Read/Write] This is a dynamic property that holds the value of the answer at the current repeat index. |
Event | Description |
![]() |
This event is fired for every value found for the particular answer. This event is fired during the processing of the Answer.IterateValues method. |
The following Visual C# example opens an answer file and displays each answer it contains:
public class ExampleCode { static string ansName; static string ansType; static void Main() { HotDocs.AnswerCollection ac = new HotDocs.AnswerCollection(); ac.Create(@"C:\Documents\HotDocs\Answers\AnswerFile.anx"); Console.WriteLine("Variable\tAnswer\tType"); foreach (HotDocs.Answer ans in ac) { ansName = ans.Name; ansType = getType(ans.Type); ans.OnValueFoundEvent += new HotDocs._AnswerEvents_OnValueFoundEventEventHandler(ans_OnValueFoundEvent); ans.IterateValues(); } Console.ReadKey(); ac.Close(); } static void ans_OnValueFoundEvent(object Value, int repeat1, int repeat2, int repeat3, int repeat4) { string index = ""; string ansValue = ""; if (repeat1 > -1) index = "[" + (repeat1 + 1).ToString() + "] "; //Check to see if the value is an array (multiple-select Multiple Choice variable) if (Value.GetType() == typeof(System.Object[])) foreach (string s in (System.Object[])Value) { ansValue += s + "; "; } else ansValue = Value.ToString(); Console.WriteLine(index + ansName + "\t" + ansValue + "\t" + ansType); } static string getType(HotDocs.HDVARTYPE type) { switch (type) { case HotDocs.HDVARTYPE.HD_DATETYPE: return "Date"; case HotDocs.HDVARTYPE.HD_MULTCHOICETYPE: return "Multiple Choice"; case HotDocs.HDVARTYPE.HD_NUMBERTYPE: return "Number"; case HotDocs.HDVARTYPE.HD_TEXTTYPE: return "Text"; case HotDocs.HDVARTYPE.HD_TRUEFALSETYPE: return "True/False"; default: return type.ToString(); } } }