Click or drag to resize
Askia

IInterviewInterpret Method

Interpret the AskiaScript contains in the specified text.

Namespace:  AskiaCore
Assembly:  AskiaCore (in AskiaCore.dll) Version: 6.0.0-build000000000000000000000000000000000000000001
Syntax
string Interpret(
	string text
)

Parameters

text
Type: SystemString
Text to interpret.

Return Value

Type: String
Interpreted string.
Examples

Interpret the AskiaScript keyword for the current date.

using AskiaCore;

namespace MyApp
{
    public class MyProgram
    {
        static void Main()
        {
            // Initialize the database connection string (Where the survey will be stored)
            Persistent.InitDatabaseConnection("connectionstring", DatabaseTypes.PORTAL);

            // Create a context with the user 1
            IContext context = ContextFactory.Create();
            context.UserId = 1;
            context.SessionId = "xxxxx-xxxxx-xxxxx-xxxxxx";
            context.LanguageId = 2057; // Edit the survey with this language (English)

            // Get the survey with the AskiaPortal id 1
            ISurvey survey = SurveyFactory.Get(context, 1);
            IInterview interview = survey.CreateInterview();

            // Specify the web context
            interview.WebInformation.Identity = "name:\"Chrome\",version:\"50.0.2661.102\",os:\"Windows\",mobile:false,tablet:false,userAgent:\"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36\",timeOffset:2";
            interview.WebInformation.Resolution = "screen-availWidth:2560,screen-availHeight:1334,screen-width:2560,screen-height:1440,screen-colorDepth:24,window-width:1708,window-height:1130";
            interview.WebInformation.Capabilities = "javascript:true";

            IDictionary<string, string> parameters = new Dictionary<string, string>();
            interview.MoveNext(parameters);
            string interpretedText = interview.Interpret("The current time is: !!Now!!");
            Console.WriteLine(interpretedText);

            // Release the database connection
            Persistent.EndDatabaseConnection();
        }
    }
}
See Also