Anatomy of a program

On this page, you will learn about the basic anatomy of the FlowScript programs you can write in script steps.

Statements

A FlowScript program consists of a series of statements. When your application is run and reaches a script step, the program statements inside it are executed top-to-bottom.

Statements are generally terminated by a semicolon (;) character. While not mandatory, the semicolons are recommended, as they help FlowScript give you better error information should you make a typo somewhere in the code.

The following example shows a program consisting of two statements. The first statement declares a variable called x and assigns it the value 1, and the second statements uses the return keyword to end the script with the value of x as its final result.

let x = 1;
return x;

Case and whitespace

FlowScript has case sensitive identifiers. The variable name user is considered distinct from the variable name User.

However, all language keywords are case insensitive. The following is valid:

RETURN 1;

For reasons of backward compatibility with Flow Classic, the names of built-in functions are also case insensitive.

In some languages, white space is a significant part of the syntax, but this it not the case in FlowScript. You may choose freely where to use white space characters such as tabs, line breaks and spaces.

Comments

You can write comments in your program. These are ignored when the application is run. There are two ways to write comments:

// Text that is prefixed by a double slash is called a line comment.
// Such a comment continues until the next line break.

let x = 1;

/* This is called a stream comment, and it begins with a slash
   followed by an asterisk.
   A stream comment may span over several lines.
   You must 'close' a stream comment by an asterisk followed by a slash. */
   
return x;

Return

A return statement ends the execution of a program and provides a result. Programs must always end with some result.

// Example: end the program and provide the number zero as its result.
return 0;

Any statement placed after a return statement is ignored.

// Example: a program with two return statements.

return 1; // This ends the program with the result 1.
return 2; // This will be ignored, because the program has already ended.

Last updated