Airscript Quickstart
Airscript is Airkit’s internal programming language. It is designed to be a simple but powerful language with a focus on data manipulation. By combining Airscript with input from app users (or other external sources, such as an external API), you can control the order, flow, and nature of the interactions between your Airkit apps and the outside world.
[block:embed] { "html": "<iframe class="embedly-embed" src="//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNxb9_dvnh3Y%3Ffeature%3Doembed&display_name=YouTube&url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNxb9_dvnh3Y&image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNxb9_dvnh3Y%2Fhqdefault.jpg&key=7788cb384c9f4d5dbbdbeffd9fe4b92f&type=text%2Fhtml&schema=youtube" width="854" height="480" scrolling="no" title="YouTube embed" frameborder="0" allow="autoplay; fullscreen" allowfullscreen="true">", "url": "https://www.youtube.com/watch?v=Nxb9_dvnh3Y", "title": "Airscript quickstart", "favicon": "https://www.google.com/favicon.ico", "image": "https://i.ytimg.com/vi/Nxb9_dvnh3Y/hqdefault.jpg", "provider": "youtube.com", "href": "https://www.youtube.com/watch?v=Nxb9_dvnh3Y", "typeOfEmbed": "youtube" } [/block]
Testing Airscript Expressions
When working with Airscript, it's often advantageous to test an Airscript expression before implementing it. https://studio.airkit.com/play/ provides a sandbox environment to test Airscript expressions outside of any application.
Functions
Like most programming languages, Airscript makes extensive use of functions. You can find documentation on all Airscript functions in the Airscript section of our reference docs.
Arithmetic Operators
Airscript supports the standard arithmetic operators: addition (+), subtraction (-), multiplication (*) , and division (/), as well as remainder (%).
Unlike Airscript functions, Airscript operators not placed before the variables they are operating on, but rather between them, analogous to how operators are written in simple arithmetic equations. For instance, the following example shows you the addition operator (+) would be used to compute 2 plus 2:
All arithmetic operators are capable of operating on Numbers and likewise returning Numbers as output. Some arithmetic operators are also capable of operating on variables of other Data Types. See documentation on individual operators for details.
Order of Operations
Airscript arithmetic operators are performed according to mathematical conventions. That is, an expression that contains multiple arithmetic operators will perform operations in the following order:
Parentheses - Operations grouped into parenthesis are resolved first.
Multiplication, Division, and Remainders - Multiplication, division, and remainder operations are resolved next. They are resolved from left to right.
Addition and Subtraction - Addition and subtraction operations are resolved next. They are resolved from left to right.
Comparison Operators
Airscript has a number of comparison operators.
Unlike Airscript functions, Airscript operators not placed before the variables they are operating on, but rather between them, analogous to how operators are written in simple arithmetic equations. For instance, the following example uses the equality operator (=) to check if 2 is equal to 2:
All comparison operators return a Boolean as output. They are commonly used in tandem with Airscript functions such as IF, which requires Boolean input.
All comparison operators are capable of comparing two Numbers, Times, Dates, DateTimes, Currencies, and strings. See documentation on individual operators for details.
Displaying Airscript Output in an App
Airscript expressions can be used to define Labels that display dynamic information. For instance, a Label defined by the following string will display declare the current date and time:
Note how the Airscript expression that consists of the functions FORMAT_DATETIME and NOW is delineated by double curly brackets. When Airscript expressions that require evaluation are inserted into strings, they are delineated by double curly brackets.
Accessing Data
Accessing Variables
Airscript expressions have access to variables, but only the variables within an accessible namespace. Different Airscript expression editors have access to different variable namespaces. For more on how to conceptualize and work with variables in Airkit, see Variable Namespaces.
Accessing Object Properties
Objects are a data type that relates field names to values. For example, an address in the United States is typically made up of a Street, City, State, and Zipcode. In Airkit, an example of an Object holding such data might look like this:
In order to access the street property, one would use dot notation:
or, if this Object is stored in a local variable called address
:
For more on how to access individual values in Objects, see Pull Values from Lists and Objects.
Accessing Items in a List
Lists are a data type that store data in a particular order. Imagine we have a list of book titles, in Airscript it might look like this:
A particular item can be accessed from a list by its numerical index in the list. Indices begin at the number zero, in other words, the first item in the list is accessed at index 0. In order to retrieve the book title "The Little Schemer" from our example you would do so like this:
or, if this list is stored in a local variable called books
:
For more on how to access items in Lists, see Pull Values from Lists and Objects.
Creating User Defined Functions
User Defined Functions (UDFs) are custom functions made out of and parsable by Airscript. They can be used as part of an application in the same way as out-of-the-box Airscript functions can, including when defining other UDFs.
UDFs are defined in the Connections Builder. For a deeper dive into how UDFs are defined, check out Creating Custom Functions.
Last updated