Airscript Quickstart
Last updated
Was this helpful?
Last updated
Was this helpful?
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 , such as an external API), you can control the order, flow, and nature of the interactions between your Airkit apps and the outside world. Most commonly, this is done by with Airscript or by using Airscript to access or modify data via the , both of which parse any input in Airscript by default.
[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": "https://www.youtube.com/", "href": "https://www.youtube.com/watch?v=Nxb9_dvnh3Y", "typeOfEmbed": "youtube" } [/block]
When working with Airscript, it's often advantageous to test an Airscript expression before implementing it. provides a sandbox environment to test Airscript expressions outside of any application.
Like most programming languages, Airscript makes extensive use of functions. You can find documentation on all Airscript functions in .
Airscript supports the standard : 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 and likewise returning Numbers as output. Some arithmetic operators are also capable of operating on variables of other Data Types. See for details.
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.
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:
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
:
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
:
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.
Airscript has a number of .
All comparison operators return a as output. They are commonly used in tandem with Airscript functions such as , which requires Boolean input.
All comparison operators are capable of comparing two , , , , , and . See documentation on individual operators for details.
Airscript expressions can be used to define 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 and is delineated by double curly brackets. When Airscript expressions that require evaluation are inserted into strings, they are delineated by double curly brackets.
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 .
UDFs are defined in the . For a deeper dive into how UDFs are defined, check out .