Sample Code of Dynamic Questions
The following sample code implements inserting an answer into a question dynamically. Specifically, it inserts the caller’s title and last name, as determined by previous questions, into the target question. The question might be entered into SmartScript as follows:
Hello. Is this [Contact.M/M] [Contact.LastName]?
Sample VB Code
Sub Question_Enter
Dim MM as String
Dim LastName as String
Dim Q as SmartScriptQuestion
Dim Text as String
Set Q = Page.GetQuestion ("Contact: Mr/Ms")
MM = Q.GetCurrentValue
Set Q = Page.GetQuestion ("Contact: Last Name")
LastName = Q.GetCurrentValue
Text = OriginalQuestionText
Text = SubstituteText (Text, "Contact.M/M", MM)
Text = SubstituteText (Text, "Contact.Last Name", LastName)
SetQuestionText (Text)
End Sub
Sample eScript Code
function Question_Enter ()
{
var MM;
var LastName;
var Q;
var Text;
Q = Page.GetQuestion ("Contact: Mr/Ms");
MM = Q.GetCurrentValue ();
Q = Page.GetQuestion ("Contact: Last Name");
LastName = Q.GetCurrentValue ();
Text = OriginalQuestionText ();
Text = SubstituteText (Text, "Contact.M/M", MM);
Text = SubstituteText (Text, "Contact.Last Name", LastName);
SetQuestionText (Text);
}