ClarioScript Guide

ClarioScript may feel familiar to users with experience in other scripting languages. There are a few special elements (e.g. Attribute references) which require special syntax. This guide covers the syntax and the core elements available when authoring ClarioScript.

Attribute Names

Attribute names may only consist of the following characters: A-Z, a-z, 0-9, ‘-‘, and ‘_’.

GoodName, good_name, good123, good-name

Attribute Types

Types are single characters S, D, or N corresponding to String, Date, Number.

For new attributes, if type is not specified, the attribute type will try to be determined. If type cannot be determined, it will be assigned the type Any (*) and result in a syntax error.

Attributes

Both attributes on the incoming stream and non-existing attributes can be expressed as [<name>]. Specifying a type, such as [<name>:<type>], will result in a syntax error.

Example:

[attr1], [my-attr], [my_attr], [undefinedAttr]

Transform Expression References

Each transform expression in the script can be reused with the syntax:

@[<name of transform definition>]

Example:

mydef1:N= abs([attr1])
mydef2:N= @[mydef1] * @[mydef1]  // will fill in the value of mydef1.

Circular references are not valid:

mydef1:N=@[mydef2]   // ERROR: Can be saved but will be invalid.
mydef2:N=@[mydef1]

Project Constants

References to project constants are allowed as {<name>}.

Example:

{PI}, {My-Date}, {Undefined}

Function Calls

Use the Expression Builder to explore the available functions:

<function name>(<arg 1>, <arg 2>, ...<arg n>)

Example:

abs(123), condition([attr1]=={mycode}, 1, 0), daysBetween('2012-09-24','1969-09-24')

Incomplete functions are allowed to be saved, although the workflow will not be valid:

abs(), condition(,,)

Operators

+,-,/,*          // Numeric only operators
==,!=,<,>,<=,>=  // Comparison operators
AND, OR          // Logical operators
()               // Parenthetical grouping

Example:

condition([attr] >= 0 OR [attr] < 1000, 5 * ([attr]+3), 0)

Constants

Strings, Numbers, Dates, and Null

Strings:

"Hello", "JAN",       // String literals are double quoted.
"\"Hi\", said Jim"    // Double quotes are escaped with a back slash.
"\\"                  // Back slashes are escaped with a double back slash.

Numbers:

123, 55.90, 999.0394845

Dates: Date are defined by single quotes and an ISO format:

'YYYY-MM-DD'
'YYYY-MM-DD HH:MM:SS' OR 'YYYY-MM-DDTHH:MM:SS'

Example:

'2012-09-24'            // Short date
'2040-12-31 14:22:02'   // Date time with space separator
'2040-12-31T14:22:02'   // Date time with optional ISO “T” separator

Null:

mydef1:N= condition([attr1] == ?, 1, 0) // Nulls are a question mark

Comments

Anything after a double forward slash is ignored by the script compiler:

fn1:S="a string" // This comment text is ignored

Note: Comments and whitespace are not stored with your code and are only useful if you want to keep a text file of common algorithms to paste into new transforms, share with co-workers, or for documentation.