Login    Sites MenuBlueStep

BlueStep Platform Support

RelateScript
Outline full outline 
Overview 
How and Where are Formulas Used? 
Basic Syntax and Behavior 
Style Guidelines 
Data Types 
Operators 
Statements 
Functions 
Working with Relate Data 
How Formulas Work 
Related Topics 

Relate Script's syntax rules (equivalent to grammar and punctuation rules in English) are mostly based on Java, which is similar to C, C++ and JavaScript. It does, however, borrow some ideas from other types of computer languages, such as SQL.

Syntax Rules and Results
Relate Script is a type-safe language, meaning that the data-type of each formula input and formula result is determined when the formula is written. The formula engine knows, before the formula runs, whether the result will be a date, a number, a piece of text or another specific data type. This allows for detection of common logic problems, such as using a date where a number should be.

Relate Script is also case-sensitive, meaning that it will treat ABCD as a totally different thing from abcd or aBcD.  Relate Script follows the same rules for variable names and other identifiers as in most case-sensitive computer languages.  Specifically, identifiers must contain only letters, numbers and the underscore character.  Also an indentifier cannot begin with a number.   All variable names, Relate field formula identifiers, Relate form formula ids, function names and field/property names must meet these naming requirements.

Relate Script allows for simple, single-expression formulas such as x = y + 4, as well as complex, multi-statement formulas with control flow structures and advanced logic. Multiple statements are separated by semi-colons, but the semi-colon can be omitted if it is at the end of a line.

As with most computer languages, whitespace (spaces, tabs, newlines) are mostly ignored. This means that x=4 is the same as
x
=       4
but would be quite silly actually written that way. 

Functions can be called with an object-oriented syntax with the first parameter before the function name as in: "asdf".toUpperCase(), or they may be called in the procedural style with all parameters inside the parentheses: toUpperCase("asdf"). Both expressions are equivalent and give the same result: "ASDF".

As the example in the previous rule implies, functions may be called on ANY appropriate value. So the following works (and results in 8): ("qwerty" + "asdf").indexOf("d")

As in JavaScript, strings (pieces of text data) can be single or double quoted: "asdf" == 'asdf'  It is important to remember, though, that the closing quote must be the same as the opening one.

Widening conversions work similar to those in Java with regard to Integer/Float.  Namely, you can always use an integer value where a floating-point value should be, but not vice-versa.

All of the basic types of data can be null and (as in SQL) nearly any operation with a null as one of the operands will result in null. So 4 + null results in null. The only exceptions are the equality/inequality operators which allow testing for null, string concatenation where null is equivalent to the empty string, and the aggregate functions sum(...), max(...), min(...) and avg(...) where null is generally ignored entirely.

New variables are created by simply assigning them a value. So the statement x = 4 would create a new Integer variable, x, and assign it the value 4. This example assumes that the variable x does not already exist. If x does already exist, then no new variable is created, instead the existing variable is assigned the value 4.

Comments are as in C++/Java: a double slash creates a comment to the end of the line.  A block comment in the middle of a line or spanning multiple lines is started with a slash then asterisk and ended with an asterisk then slash. Here are some comment examples:
    x = 4 // end of line comment
    // full line comment
    y = /* middle of line comment */ 19;
    /* This is a multi-line
    comment */