AskiaScript 2.0 is fully object-oriented. This means that each variable has properties (that hold information about the variable) and methods (that allow you to perform an operation on the variable). This makes for much more elegant scripts, which are easier to write and maintain.
Let's imagine we have the string "Hello world! The world is nice!" and we want to replace the word "Hello" with "Hi". In AskiaScript 1.0, we could do this by using the replace function:
Replace("Hello world! The world is nice!", "Hello", "Hi")
If we wanted to replace multiple words, e.g. replacing "world" with "people" and "Hello with "Hi" and replace the exclamation mark by a full stop, the replacement would be more complex:
Replace(Replace(Replace("Hello world! The world is nice!", "Hello", "Hi"), "world", "people"), "!", ".")
This makes the script too complex to read and to edit.
AskiaScript 2.0's object-oriented nature makes the code much more readable, as the object (in this case the text string) handles the function's execution. In AskiaScript 2.0, we could the operation as follows:
dim text = "Hello word! The world is nice!"
text.Replace("Hello", "Hi").Replace("world", "people").Replace("!", ".")
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents. A variable name in computer source code is usually associated with a data storage location and thus also its contents, and these may change during the course of program execution (Source from Wikipedia)
In AskiaScript, all variable names case-insensitive, which means that ABC and abc refer to the same variable.
In most programming languages, a variable has a scope, which determines where the variable is visible (the variable cannot be used outside of this scope). In AskiaScript, the top scope level (global scope) is interview-based: all global variables (questions / system variables) are available only for the current interview and not across interviews. Lower-scope (called local scope) variables are available only inside of a condition, action or inline script.
AskiaScript provides three kinds of variables:
System variables in the global scope
Question variables in the global scope
Declarative variables in the local scope