ADX type object

Available from version 5.3.3.

In AskiaScript, ADX, or Askia Design eXtension, encapsulates both ADC (Askia Design Control) and ADP (Askia Design Page). It is an object that can be used inside an ADX and provides the ADX context and useful information about the currently displayed ADX. This variable is in the ADX scope, so is available only on the ADX itself. It is accessible through a local variable named CurrentADC for an ADC or CurrentADP for an ADP.

See also:

In this topic:

Properties

InstanceId

Returns the unique identifier of the ADX instance displayed on the page. The same ADX could appear several times on the same page, with each instance having its own unique identifier that can be retrieved through this property.

Returns a Number.

Example
CurrentADC.InstanceId  ' => 1, for the first ADC instance 
' available in the current page

↑ Top of page ↑

Name

Returns the name of the ADX.

Returns a String.

See also: <name>

Examples
CurrentADC.Name ' => "Gender"
CurrentADP.Name ' => "MyBeautifulPage"

↑ Top of page ↑

OutputId

Returns the ID of the current, in-use, ADX output.

Returns a String.

See also: Output selection rules.

Examples
CurrentADC.OutputId ' => "mobileHTMLOutput"
CurrentADP.OutputId ' => "DesktopPage"

↑ Top of page ↑

MasterPage

Available from version 5.4.2.
Available for ADPs only.

Returns the file-name of the master page in use. Using it in an ADC will return an empty string.

Returns a String.

Also see: Output selection rules.

Examples
CurrentADP.MasterPage' => "DesktopPage"
CurrentADC.MasterPage ' => "" 'No master page inside ADC

↑ Top of page ↑

Properties

Returns the entire collection of properties defined in the ADX.

Returns a collection of ADX Properties.

See also: <properties>

Examples
CurrentADC.Properties.Count ' => 2
CurrentADC.Properties[1] ' => <ADXProperty::tickColor>
CurrentADP.Properties[2] ' => <ADXProperty::autoSubmit>

↑ Top of page ↑

Contents

Returns the list of ADX contents (files) in the currently-selected ADX output.

Returns an Array of ADX Content.

See also: <content>.

Examples

CurrentADC.Contents.Count ' => 2

CurrentADC.Contents[1] ' => <ADCContent::dynamic:default.html>
CurrentADP.Contents[1] ' => <ADCContent::dynamic:styles.css>

↑ Top of page ↑

Errors

Available from version 5.6.0.

Returns the list of errors during the interview associated with the ADC. This allows ADCs to indicate if there is an error associated with a specific entry, as opposed to the page as a whole.

See also: Error

Returns an Array of Errors.

Example
CurrentADC.Errors.Count ' => 0
CurrentADC.Errors[1].Key ' => "expected_answer"
CurrentADC.Errors[1].Message ' => "A response is expected for question 'q1'"
{% If CurrentADC.Errors.Count Then %}
<ul class="question-errors"><li>{%= CurrentQuestion.ShortCaption %}
  <ul>
     {% Dim errIter 
        For errIter = 1 To CurrentADC.Errors.Count
     %}
        <li>{%= CurrentADC.Errors[errITer].Message %}</li>
     {% Next %}
  </ul>
</li></ul>
{% EndIf %}

Produces:

<ul class="question-errors"><li>Ranking
   <ul>
      <li>Rank 2 is missing for question `Ranking`</li>
      <li>Rank 3 has been given more than once for question `Ranking`</li>
   </ul>
</li></ul>

↑ Top of page ↑

Methods

Var(propertyId)

Available from version 5.4.2.

Returns the value of the ADX property as a variant. If the value of the variable is an object (like a question), the system calls its ToString() method. If you want to access the question object associated with the variable, use the PropQuestion method instead.

Returns a Variant.

The inner type of the variant depends on the type of the property, as follows:

This is a shorthand for:

CurrentADC.GetProperty( propertyId ).Value
Parameters
Examples
If CurrentADC.Var("enableTooltip") = true Then
' Rest of the code
End If
{%= CurrentADC.Var("tickColour") %} ' Print: 0,255,0
CurrentADC.Var("boxNumbers").ToNumber() + 1 ' 12 + 1
CurrentADC.Var("additionalQuestion").InnerTypeOf() ' => "string"
CurrentADC.Var("additionalQuestion") ' => "{
"shortcut":"q1", 
"shortCaption":"Q1", 
"longCaption":"Q1", 
"type":"single" 
}"

↑ Top of page ↑

PropValue(propertyId)

Returns the value of the ADX property as a string. If the value of the variable is an object (like a question), the system calls its ToString() method. If you want to access the question object associated with the variable, use the PropQuestion method instead.

This is a shorthand for:

CurrentADC.GetProperty( propertyId ).Value.ToString()

Returns a String (take note).

Parameters
Examples
CurrentADC.PropValue("defaultDisplay") ' => "FlashEnable"
CurrentADC.PropValue("tickColour") ' => "0,255,0"
CurrentADC.PropValue("additionalQuestion") ' => "{
"shortcut":"q1", 
"shortCaption":"Q1", 
"longCaption":"Q1", 
"type":"single" 
}"

↑ Top of page ↑

PropQuestion(propertyId)

Returns the question associated with the ADX property (type question). This is shorthand for:

CurrentADC.GetProperty( propertyId ).Question 

Returns a Question.

Parameters
Examples
CurrentADC.PropQuestion("other") ' => <Question::Q1_Other>
CurrentADC.PropQuestion("other").Shortcut ' => "Q1_Other"

↑ Top of page ↑

PropsToJSONObject([names][, dontWrap])

Available from version 5.4.2.

Returns a key/value pair of properties using the JSON Object representation.

Returns a String.

Parameters
Note: Please ensure the value is correctly converted, according to the property type, as follows:
Examples
CurrentADC.PropsToJSONObject()
' { 
'    "prop1" : "value1",
'    "prop2" : "value2",
'    "prop3" : true,
'    "prop4" : 12
' }   
CurrentADC.PropsToJSONObject({"prop1"; "prop4"})
' { 
'    "prop1" : "value1",
'    "prop4" : 12
' }   
CurrentADC.PropsToJSONObject({"prop1"; "prop4"}, true) ' Don't wrap
'    "prop1" : "value1",
'    "prop4" : 12

Build a complex JSON representation using don't wrap and wrap.

var obj = {
  {%= CurrentADC.PropsToJSONObject({"prop1"; "prop4"}, true) ' Don't wrap %}
  , "subKeys" : {%= CurrentADC.PropsToJSONObject({"prop2"; "prop3"}) ' Wrap %}
}; // End

' var obj = {
'    "prop1" : "value1",
'    "prop4" : 12
'    , "subKeys" : {
'       "prop2" : "value2",
'       "prop3" : true
'    }
' }; // End

↑ Top of page ↑

PropsToJSONArray([names][, dontWrap])

Available from version 5.4.2.

Returns an array of property values, separated with comma delimiters (JSON representation of array).

Returns a String.

Parameters
Note: Please ensure the value is correctly converted, according to the property type, as follows:
Examples
CurrentADC.PropsToJSONArray()
' ["value1", "value2", true, 12' ]
CurrentADC.PropsToJSONObject({"prop1"; "prop4"})
' ["value1", 12 ]   
CurrentADC.PropsToJSONObject({"prop1"; "prop4"}, true) ' Don't wrap
' "value1", 12

Build a complex JSON representation using the don't wrap and wrap.

var arr = [
  {%= CurrentADC.PropsToJSONArray({"prop1"; "prop4"}, true) ' Don't wrap %}
  , {%= CurrentADC.PropsToJSONObject({"prop2"; "prop3"}) ' Wrap (sub-array) %}
]; // End

' var arr = [
'    "value1", 12
'    , ["value2", true]
' ]; // End

The don't wrap could also be use to call javascript function with the properties as arguments:

console.log({%= CurrentADC.PropsToJSONArray({"prop1"; "prop4"}, true) ' Don't wrap %});
' console.log("value1", 12);

↑ Top of page ↑

GetProperty(propertyId)

Returns the property object with the specified id.

Returns an ADX Property.

Parameters

See also: <properties>

Examples

CurrentADC.GetProperty("tickColor")

' => <ADCProperty::tickColor>
CurrentADC.GetProperty("tickColor").Name 
' => "Tick color"

↑ Top of page ↑

GetContent(location)

Returns the ADX content with the specified location.

See also: Content location

Returns an ADX Content.

Parameters
Examples
CurrentADC.GetContent("share/jquery.js") ' => <ADCContent::share:jquery.js>
CurrentADC.GetContent("static/styles.css").Type ' => "css"

↑ Top of page ↑

URLTo(location)

Returns the relative URL path to the content file at the specified location.

Returns a String.

For a dynamic file:

Also see: Content location

Parameters
Examples
CurrentADC.URLTo("static/tick.png") 
' => "../Resources/[Survey]/[ADC]/tick.png"
CurrentADC.URLTo("shared/jquery.js") 
' => "../Resources/[Survey]/jquery.js"
CurrentADC.URLTo("dynamic/default.js")
' => "AskiaExt.dll?Action=GetADCContent
'                 &SurveyName=TestSurvey
'                 &Intvw=BNYOXYCYVIUJDBBD
'                 &Position=4
'                 &ADCName=GenderADC
'                 &InstanceId=1
'                 &Content=dynamic/default.js"

↑ Top of page ↑

ShowMessage(string)

Available from version 5.5.2

Returns the HTML code of the ADP as string.

Returns a String.

This method is to use in the final pages and if you use also SetProperty() and/or Redirect() methods, then you need to use ShowMessage() at the end.

Parameters
Examples
!!CurrentADP.ShowMessage("my message")!!
!!CurrentADP.SetProperty("display_previous","no").SetProperty("display_next","no").Redirect("http://www.askia.com",5).ShowMessage("
<center>
<br/>
Thank you for your participation<br/><br/>
You will be redirect in <span id='countdown'>5</span> s<br/><br/>
</center>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', function(event) {
	var timeleft = 4;
	var downloadTimer = setInterval(function(){
		document.getElementById('countdown').innerHTML = timeleft;
		timeleft -= 1;
		if (timeleft <= 0){
			clearInterval(downloadTimer);
		}
	}, 1000);
});
</script>
")!!

↑ Top of page ↑

SetProperty("idproperty","value")

Available from version 5.5.2

Returns the current ADP with the modified property.

This method is to use in the final pages and you need to use ShowMessage() at the end.

Parameters
Examples
!!CurrentADP.SetProperty("display_previous","no").SetProperty("display_next","no").Redirect("http://www.askia.com",5).ShowMessage("
<center>
<br/>
Thank you for your participation<br/><br/>
You will be redirect in <span id='countdown'>5</span> s<br/><br/>
</center>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', function(event) {
	var timeleft = 4;
	var downloadTimer = setInterval(function(){
		document.getElementById('countdown').innerHTML = timeleft;
		timeleft -= 1;
		if (timeleft <= 0){
			clearInterval(downloadTimer);
		}
	}, 1000);
});
</script>
")!!

↑ Top of page ↑

Redirect("url",seconds)

Available from version 5.5.2

Returns the current ADP with a meta http-equiv refresh added in the head of the html page.

This method is to use in the final pages and you need to use ShowMessage() at the end.

Parameters
Examples
!!CurrentADP.SetProperty("display_previous","no").SetProperty("display_next","no").Redirect("http://www.askia.com",5).ShowMessage("
<center>
<br/>
Thank you for your participation<br/><br/>
You will be redirect in <span id='countdown'>5</span> s<br/><br/>
</center>
<script type='text/javascript'>
document.addEventListener('DOMContentLoaded', function(event) {
	var timeleft = 4;
	var downloadTimer = setInterval(function(){
		document.getElementById('countdown').innerHTML = timeleft;
		timeleft -= 1;
		if (timeleft <= 0){
			clearInterval(downloadTimer);
		}
	}, 1000);
});
</script>
")!!

↑ Top of page ↑

ToString()

Returns a string which represents the ADX object, in JSON notation.

CurrentADC.ToString() ' => {
 "name":"Gender",
 "guid":"0dba9f18-a026-421e-afa9-0ec01128a663",
 "version":"2.0.0",
 "date":"2012-03-05",
 "description":"Question gender",
 "categories":[ "Gender", "Closed" ],
 "author":"Jerome Duparc, Mamadou Sy",
 "company":"Askia SAS",
 "helpURL":"http://dev.askia.com",
 "site":"http://www.askia.com" 
}
CurrentADP.ToString() ' => {
 "name":"MyBeautifulPath",
 "guid":"17e47dff-8d4b-4ab9-a461-78f2388acd22",
 "version":"1.0.0",
 "date":"2015-12-16",
 "description":"Beautiful page template with auto-submit",
 "categories":[ "Auto-submit" ],
 "author":"John Doe",
 "company":"My company",
 "helpURL":"http://my.helpurl.com",
 "site":"http://my.url.com" 
}

↑ Top of page ↑

TypeOf()

Always returns "adc" or "adp".

Returns a String.

Examples
CurrentADC.TypeOf() ' => "adc"
CurrentADP.TypeOf() ' => "adp"

↑ Top of page ↑

Content location

The content location is a special relative URL based on the ADX Resources folder. To get a specific ADX Content or the final URL of a file under the ADC Resources folder, you may use the following location pattern:

Mode/FileName

Where Mode could be "share", "static" or "dynamic" and FileName is the full name of the file to be obtained.

Example:

shared/jquery.js
static/styles.css
dynamic/controls.html

↑ Top of page ↑

Create your own Knowledge Base