Quick is a simple procedural language for scripting apps in Codeless. The scripts are compiled into Swift when the app is exported to native code.

Quick is designed to be simple, learnable, and complete without being clever. It eschews users building their own classes and functions, and concentrates on common functionality. Built-in methods often operate at a higher level than their Swift counterparts, allowing less code to be written, and thereafter debugged.

Table of Contents

Multiline Statements

A quick script is made up of one or more valid statements. These statements are detailed below.

Quick is not whitespace sensitive, however spaces are required between keywords. Newlines are used to separate statements. One or more newlines can be used between each statement.

Quick Example Code - Three trivial statements, separated by newlines.
foo = 10
bar = foo * 10
print(bar)


Statements

A quick script is made up of one or more valid statements. These statements can be assignments, for loops, while loops, if statements, method calls, returns, or comments. A value by itself on a line is not a valid statement.


Assignments

Quick scripts can assign values to variables or interface variables. Interface variables are declared automatically by the UI you've created in Codeless and contain a '.' character. If you attempt to assign the wrong type of data to an interface variable, you'll receive an error when editing the script.

Quick Example Code - Assigning a value to an interface variable.
view.backgroundColor = #FF0000

Variables are declared when you use them, and do not contain a '.' character. The type of the variable is inferred when it's first assigned, and is kept static thereafter. If you attempt to assign a different type of data to a variable, you'll receive an error when editing the script.

Quick Example Code - Assigning a value to a variable.
myBackground = #FF0000

Occasionally you may access a variable where the compiler cannot infer a type. In these cases, you'll recieve an error unless you cast the variable using the 'as' keyword.

Quick Example Code - Casting a variable to a specific type.
myBackground = getAppVariable("background") as Color

Attempting to cast a value of a non-matching type will result in recieving a default value of the cast type.

Quick Example Code - Casting a value to the wrong type.
color = #FF0000
newColor = color as Dictionary
// newColor now contains an empty dictionary


For Loops

A for loop iterates through each item in an array and sets a variable for the scope of the loop.

Quick Example Code - Summing an array using a for loop.
sum = 0
myArray = [1, 2, 3]
for i as Integer in myArray {
sum = sum + i
}
// Sum now equals 6


While Loops

A while loop continues executing as long as it's logical expression evaluates to true.

Quick Example Code - Finding the first '1' in an array.
index = 0
myArray = [0, 2, 3, 3, 1, 4, 6]
testInteger = myArray[index] as Integer
while myArray[index] != 1 {
index = index + 1
testInteger = myArray[index] as Integer
}
// index will now equal 4


If Statements

If statements take a logical expression and evaluate it's success block when it evaluates to true.

Quick Example Code - Comparing integers.
foo = 1
if foo == 1 {
print("Foo equals 1")
}
// Prints 'Foo equals 1'

If an else block is supplied, the failure block is evaluated if the logical statement evaluates to false.

Quick Example Code - Comparing integers that aren't equal.
foo = 1
if foo == 2 {
print("Foo equals 1")
} else {
print("Foo isn't 1")
} // Prints 'Foo isn't 1'


Method Calls

Quick contains a standard library of several dozen methods. We intend to regularly continue adding methods to enhance the functionality of Codeless.

Most methods have a return type, but some may return a result of any type. Those methods require a cast or the compiler will display an error during editing..

Quick Example Code - Counting an array.
foo = [1, 2, 3]
count = countArray(foo)
print(count)
// Will print '3'

Most methods have a return type, but some may return a result of any type. Those methods require a cast or the compiler will display an error during editing.

Quick Example Code - Getting an app variable.
foo = getAppVariable("background") as Color

Methods consist of a method name, a first parameter, and then named parameters for the other arguments.

Quick Example Code - Checking if a key exists in a dictionary.
foo = {"some key": "some value", "another key": "another value"}
doesExist = keyExists("some key", inDictionary: foo)

You can view a complete list of methods.


Return Statements

Some scripts require a return value. Returning a value stops execution at that point.

Quick Example Code - Returning an integer
foo = 10
return foo


Comments

Comments are non-executable statements used for documentation, prefaced by '//'. Quick comments can go on a line by themselves or at the end of another line. There are no multiline comments in Quick.

Quick Example Code - Comments for documentation
if switch.isOn == true {
view1.backgroundColor = #FF0000 // Make background red
}




Values

Quick contains several built in types: Booleans, Integers, Floats, Strings, Arrays, Dictionaries, Colors, Coordinates, Rects, and Enums. These types are detailed below.


Booleans

Booleans are simple true or false values.

Quick Example Code - Declaring booleans
foo = true
bar = false


Integers

Integers are whole numbers, either positive or negative.

Quick Example Code - Declaring integers.
foo = -120
bar = 0
frob = 5


Floats

Floats are decimal numbers, either positive or negative. A Float must include a decimal point, or else it will be considered an Integer.

Quick Example Code - Declaring floats.
foo = -120.0
bar = 0.0
frob = 5.0


Strings

Strings are sequences of characters. They're declared by enclosing a sequence in double quotes.

Quick Example Code - Declaring strings.
foo = "Hello World"


Arrays

Arrays are ordered collections of other values. They're declared by enclosing a comma separated list of values in square brackets. Quick arrays are zero-indexed.

Quick Example Code - Declaring arrays.
foo = [1, 2, 3]

You can dereference a value in an array by using the dereference syntax.

Quick Example Code - Getting a value from an array.
foo = [1, 2, 3]
bar = foo[1]
// bar now contains '2'


Dictionaries

Dictionaries are key-value collections where the key is a String and the value is any value type.

Quick Example Code - Declaring a dictionary.
foo = {"some key": "some value", "another key": "another value"}

You can dereference a value in a dictionary by using the dereference syntax.

Quick Example Code - Getting a value from an array.
foo = {"some key": "some value", "another key": "another value"}
bar = foo["some key"]
// bar now contains 'some value'


Colors

Colors are declared in hexidecimal, similar to how CSS handles them. The declared colour can be six or eight characters long, with the final two characters standing for the alpha value in an eight character colour.

Quick Example Code - Declaring a colour.
foo = #FF0000 // Red
bar = #FF000077 // Red with half alpha


Coordinates

Coordinates are a pair of float values that denote an x and y value.

Quick Example Code - Declaring a coordinate.
foo = (50.0, 100.0)


Rects

Rects are a set of four float values.

Quick Example Code - Declaring a rect.
foo = (50.0, 100.0, 200.0, 200.0)


Enums

Enums are fixed sets of values that are settable on specific properties. See the 'UI Elements' section for lists of enums as they apply to properties.

Quick Example Code - Declaring a rect.
datePicker.mode = .countDownTimer




Math Expressions

Quick allows several math operations: addition, subtraction, multiplication, division, and modulus. All Quick math operations are between two Floats or two Integers, and cannot use mixed types.


Addition

Addition returns the sum of two numbers.

Quick Example Code - Adding numbers
foo = 1 + 1
// foo now contains 2
bar = 1 + 1 + 2
// bar now contains 4


Subtraction

Subtraction returns the difference of two numbers.

Quick Example Code - Subtracting numbers
foo = 2 - 1
// foo now contains 1
bar = 5.0 - 1.0 - 1.5
// bar now contains 2.5


Multiplication

Multiplication returns the product of two numbers.

Quick Example Code - Multiplying numbers
foo = 1 * 1
// foo now contains 1
bar = 4.0 * 5.0 * 6.0
// bar now contains 120.0


Division

Division returns the quotient of two numbers.

Quick Example Code - Dividing numbers
foo = 4 / 2
// foo now contains 2
bar = 5.0 / 2.0 / 1.0
// bar now contains 2.5


Modulus

Modulus returns the remainder after dividing two numbers.

Quick Example Code - Finding the remainder
foo = 4 % 3
// foo now contains 1
bar = 6.0 % 7.0
// bar now contains 6.0




Logical Expressions

Quick allows several logical operations: and, or, not, equals, not equal, less than, greater to, less than or equal to, and greater than or equal to. All logical operators evaluate to either true or false.


And

And takes two Booleans and returns true if both Booleans are true. If either Boolean is false, And returns false.

Quick Example Code - Using And
foo = true and true
// foo now contains true
foo = false and true
// foo now contains false
foo = true and false
// foo contains false
foo = false and false
// foo contains false


Or

Or takes two Booleans and returns true if either Boolean is true. If both Booleans are false, Or returns false.

Quick Example Code - Using Or
foo = true or true
// foo now contains true
foo = false or true
// foo contains true
foo = true or false
// foo contains true
foo = false or false
// foo now contains false


Not

Not takes one Boolean and returns the opposite.

Quick Example Code - Using Not
foo = !true
// foo now contains false
foo = !false
// foo now contains true


Equals

Equals checks to see if two values are equivalent. In the case of Booleans, Integers, Floats, Strings, Colors, Coordinates and Rects, strict equivalence is used. In the case of Arrays and Dictionaries, each member is tested for equality with the corresponding key or index of the second collection. If two differently typed objects are compared, Equals returns false.

Quick Example Code - Testing Equality
foo = 4 == 2
// foo now contains false
bar = #FF0000 == #FF0000
// bar now contains true


Not Equal

Not equal returns the opposite result of the equals expression.

Quick Example Code - Testing Inequality
foo = 4 != "four"
// foo now contains true
bar = 4 != 4
// bar now contains false


Less Than

Less Than takes two values and returns true if the first value is strictly less than the second.

Quick Example Code - Testing Ordering
foo = 2 < 4
// foo now contains true
bar = 5.0 < 3.0
// bar now contains false


Greater Than

Greater Than takes two values and returns true if the first value is strictly greater than the second.

Quick Example Code - Testing Ordering
foo = 2 > 4
// foo now contains false
bar = 5.0 > 5.0
// bar now contains false


Less Than Or Equal To

Less Than Or Equal To takes two values and returns true if the first value is less than or the same as the second.

Quick Example Code - Testing Ordering
foo = 2 <= 4
// foo now contains true
bar = 5.0 <= 5.0
// bar now contains true


Greater Than Or Equal To

Greater Than Or Equal To takes two values and returns true if the first value is greater than or the same as the second.

Quick Example Code - Testing Ordering
foo = 2 >= 4
// foo now contains false
bar = 5.0 >= 5.0
// bar now contains true