Skip to main content

Scripting

Script Languages

The Sequentum Cloud scripting engine supports C# , Python, Java Script and Regular Expressions. 

This manual does not explain C#, Java Script and Python syntax. Please visit suitable online reference guides for more information about these languages.

Regular Expressions

Regular expression scripts in Sequentum Cloud can include any number of regex match and replace operations. Each regex operation must be specified on two lines. The first line must contain the regex pattern and the second line must contain the operation.

If a regex script contains more than one regex operation, the next operation will work on the output from the preceding operation. All regex operations are case insensitive and line breaks are ignored. The following eight special operations can be specified on a single line:

  • match - It is the first keyword from where the regex matching initiates.

  • extract - This keyword is used in place of the return keyword when other regex operations are added.

  • return - Returns the first match in the original content or a selected group within the match. The returned match can be combined with static text.

  • if - This keyword is used to create conditional statements.

  • replace - Used to replace a string with new substring.

  • sequence - This keyword is used to return a range of series.

  • identifier - It is used to return the unique identifier value

  • delay - used to return the content after some specified delay

  • upper - it converts text to uppercase.

  • lower - it converts text to lowercase.

  • capitalize - it capitalizes each word’s first alphabet

  • unescape - to unescape a string

  • url-decode - used to decode a URL.

  • url-encode - used to encode a URL.

  • html-decode - used to decode HTML string.

  • html-encode - used to encode HTML string.

  • strip-html - to strip HTML tags from the string.

  • convert-html-breaks - used to break the HTML tags 

  • trim - trims extra spaces from the beginning and from the end of the string.

  • reset - 

The syntax {$content_name} can be used to reference extracted data, input data, global data or input parameters. For example, if you had a capture command named product_id, you could construct the following regular expression to extract all text between the product ID and the first white space:

CODE
${product_id}(.*?)\s

The specified name may reference a capture command name, a data provider command name, an input parameter name or a global data name. The script will first try and find a matching capture command, then a matching data provider command, then an input parameter name and lastly a global data name. If the data from one source does not exist or is empty, the script will proceed to the next data source.

Following are a few examples:

Regular Expression

Description

match (.*)
return ${1}

Returns the entire match in this case.

match (.*)

return ${1}
replace , “”

Replaces ‘,’ with null value from the matched case.

sequence 1 to 10

Generates a sequence of comma separated values from 1 to 10

match (.*)
extract ${1}
upper

Returns the matching content in upper case

match (.*)
extract ${1}
lower

Returns the matching content in lower case

match (.*)
extract ${1}
capitalize

Returns the matching case with each word’s first alphabet capitalized.

match (.*)
extract ${1}
unescape

Returns unescaped case for the matched content.

match (.*)
extract ${1}
url-decode

Returns decoded URL of the matched string.

match (.*)
extract ${1}
url-encode

Returns encoded URL of the matched string

match (.*)
extract ${1}
html-decode

Returns decoded HTML content of the matched string.

match (.*)
extract ${1}
html-encode

Returns encoded HTML content of the matched string

match (.*)
extract ${1}
strip-html

Returns matched string with HTML tags removed

match (.*)
extract ${1}
trim

Returns matched string with extra spaces trimmed from beginning and end.

NOTE: Manual does not explain regular expression syntax. Please visit the following website for more information about regular expressions: Regular Expressions Reference Guide

Python

Python is a powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting. There is extensive support for the Python language in Sequentum Cloud.

Following is a simple example that demonstrates the use of Python language in Sequentum Cloud:

The following code is in Python to read a file from script by getting the name of the file from the Agent Parameters:

Python Code

CODE
from se_scripting_utils import *
import os
def get_data(context: RunContext):
    file_name = context.global_data.get_string("InputFileName")
    file_path = context.private_files.get_file(file_name)
    with open(file_path, 'r') as input_file:
        return input_file.read()

C#

The Sequentum Cloud scripting engine supports C# language that can be used for all types of scripts.

Kindly note, this manual does not explain C# syntax. You can always refer to suitable online reference guides for more information about these languages.

The C# scripting language initiates with a CustomScript method of the boolean type. One can always update the script as per user requirements. The signature of the method depends on the type of script.

A script can have more than one function and can also use functionality from external .NET libraries. All external .NET libraries must be added to the agent as a .dll file and then can be called using an assembly reference in the script. 

Following is a simple example depicting code in C# to read a file from script by getting the name of the file from the Agent Parameters that demonstrates the use of C# language in Sequentum Cloud:

C# Code

CODE
#r System.IO.dll
using System.IO
public string GetData (RunContext context){
var fileName = context.GlobalData.GetString("InputFileName");
var filePath = context.PrivateFiles.GetFile(fileName);
var inputFile = File.ReadAllText(filePath);
return inputFile;
}

Javascript

Javascript scripts must have one class named getdata with a static function that is executed by Sequentum Cloud. The signature of the static method depends on the type of script. Please refer to the following example:

CODE
function getData(/** @type {JavaScriptRunContext} */ context) 
{
    return "";
}

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.