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.

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:

2 + 2 -> 4

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:

  1. Parentheses - Operations grouped into parenthesis are resolved first.
  2. Multiplication, Division, and Remainders - Multiplication, division, and remainder operations are resolved next. They are resolved from left to right.
  3. 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:

2 = 2 -> TRUE

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:

"It is currently {{
  FORMAT_DATETIME(
    NOW(),
    "MMMM Do, YYYY h:mm A z"
  )
}}."

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:

{  
  street: "200 California Ave.",  
  city: "Palo Alto",  
  state: "CA",  
  zip: "94036"  
}

In order to access the street property, one would use dot notation:

({  
  street: "200 California Ave.",  
  city: "Palo Alto",  
  state: "CA",  
  zip: "94036"  
}).street

or, if this Object is stored in a local variable called address:

address.street

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:

[  
  "The Little Schemer",  
  "The Seasoned Schemer",  
  "The Reasoned Schemer",  
  "The Little Prover",  
  "The Little Typer"  
]

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:

[  
  "The Little Schemer",  
  "The Seasoned Schemer",  
  "The Reasoned Schemer",  
  "The Little Prover",  
  "The Little Typer"  
][0]

or, if this list is stored in a local variable called books:

books[0]

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.