Skip to main content
Version: 2.0.0

QuickScript

What is QuickScript?

QuickScript is a limited language, which introduces

  1. custom functions in places where
  2. large scale scripting languages would be overkill.

The language is simple and quick to use - as the name implies - and customized to the application. Functionality and methods will be added over time. If you have suggestions, then please submit them to [support@layline.io](mailto: support@layline.io).

Where can I use QuickScript?

QuickScript can be used in various places throughout the configuration of a layline.io Project. One example would be in the Mapping Asset. Therein and within the definition the individual mappings, you can use QuickScript to apply minor transformations and checks in order to determine the value to be mapped.

In the example below (1) spaces contained in element source.SMSC.SUPLSERVICE are wiped out using the strReplace method.

cff9bae6.png

Another example (2) shows how a string can be easily padded we three leading zeros.

00a0f1e6.png

Other places where QuickScript can be used:

Language Reference

Data Types

Primitives

Types
TypeDescriptionRange
BooleanRepresent true or false values.true / false
CharacterSingle 16-bit Unicode character.from'\u0000' to '\uffff' inclusive, that is, from 0 to 65535
DateTimeA date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00. The underlying data type corresponds to Java's OffsetDateTime class. Java's class methods are not supported.
DecimalImmutable, arbitrary-precision signed decimal numbers. Use this for precise calculations, e.g. for money representations. Based on Java's BigDecimal data types.from 1.40129846432481707e-45 to 3.40282346638528860e+38 (positive or negative)
DoubleDouble-precision 64-bit IEEE 754 floating point. For decimal values, this data type is generally the default choice. As mentioned above, this data type should never be used for precise values, such as money calculations.from 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative).
Long64-bit two's complement integer.from -9223372036854775808 to 9223372036854775807, inclusive
StringSequence/array of Character values.
ByteStringImmutable sequence of bytes.
Primitive Operations

The following operations are supported in the given precedence:

PrecedenceOperationOperator(s)
1unary~ !
2multiplicative* / %
3additive+ -
4bitwise shift<< >>
5relational< > <= >=
6equality== !=
7bitwise AND&
8bitwise exclusive OR^
9bitwise inclusive OR|

Reference Data Types

TypeDescription
MessageAccessorPath to a data format structure. This will point to a an element in a internal data dictionary structure, e.g. a leaf or field.

Operations

DateTime Operations

dtAddDays

Add a number of days to a provided date and time.

dtAddDaysDescription
SignaturedtAddDays(DateTime input, Long daysToAdd
Parametersinput - The date and time to add days to.
daysToAdd - Number of days to add.
ReturnsDateTime - Date with added days.
dtAddHours

Add a number of hours to a provided date and time.

dtAddHoursDescription
SignaturedtAddHours(DateTime input, Long hoursToAdd
Parametersinput - The date and time to add hours to.
hoursToAdd - Number of hours to add.
ReturnsDateTime - Date with added hours.
dtAddMinutes

Add a number of minutes to a provided date and time.

dtAddMinutesDescription
SignaturedtAddMinutes(DateTime input, Long minutesToAdd
Parametersinput - The date and time to add minutes to.
minutesToAdd - Number of minutes to add.
ReturnsDateTime - Date with added minutes.
dtAddSeconds

Add a number of minutes to a provided date and time.

dtAddSecondsDescription
SignaturedtAddSeconds(DateTime input, Long secondsToAdd
Parametersinput - The date and time to add seconds to.
secondsToAdd - Number of seconds to add.
ReturnsDateTime - Date with added seconds.
dtCreate

Create a date from given date and time parameters

dtCreateDescription
SignaturedtCreate(Long year, Long month, Long day, Long hour, Long minute, Long second)
Parametersyear - Year of date, e.g. "2022".
month - Month of date ("1-12").
day - Day of date ("1-31")
hour - Hour of time ("0-24")
minute - Minute of time ("0-60")
second - Second of time ("0-60")
ReturnsDateTime - Created date and time.
dtEpochSecond

Get the number of seconds which have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds. This is the Unix epoch (or Unix time or POSIX time or Unix timestamp).

dtEpochSecondDescription
SignaturedtEpochSecond(DateTime input)
Parametersinput - Date and time for which to calculate epoch seconds.
ReturnsLong - Epoch seconds for date since January 1, 1970.

Bit Operations

bitIsSet

Check whether a bit in a Long number is set a certain position.

bitIsSetDescription
SignaturebitIsSet(Long input, Long bitNumber)
Parametersinput - Long number which to check for a certain bitflag.
bitNumber - Position at which to check whether a bit is set or not (0-63).
ReturnsBoolean - true if bit is set, else false.

Math Operations

max

Returns the larger of two numbers. Types Decimal, Double, and Long are supported. Provided numbers must be of the same type.

maxDescription
Signaturemax(Decimal left, Decimal right)
Parametersleft - First number
right - Second number.

Types Decimal, Double, and Long are supported.
ReturnsLarger of the two numbers. Return type is the same as the given number types.
min

Returns the smaller of two numbers. Types Decimal, Double, and Long are supported. Provided numbers must be of the same type.

minDescription
Signaturemin(Decimal left, Decimal right)
Parametersleft - First number
right - Second number.

Types Decimal, Double, and Long are supported.
ReturnsSmaller of the two numbers. Return type is the same as the given number types.

Message Operations

msgCrc64

Returns a 64-bit checksum for a given MessageAccessor path. The path must exist.

msgCrc64Description
SignaturemsgCrc64(MessageAccessor accessor)
Parametersaccessor - A valid layline.io data dictionary accessor path.
ReturnsLong - CRC checksum.
ExamplemsgCrc64(message.myPath.mySubPath)
msgExists

Checks whether a given MessageAccessor path exists. Use this to check if specific data paths are filled.

msgCrc64Description
SignaturemsgExists(MessageAccessor accessor)
Parametersaccessor - Path to check for existence.
ReturnsLong - CRC checksum.
ExamplemsgExists(message.myCompany.myData.xyz.Header)

String Operations

strConcat

Returns a string concatenated from two given strings.

strConcatDescription
SignaturestrConcat(String left, String right
Parametersleft - First string.
right - Second string.
ReturnsString - Concatenated string.
ExamplestrConcat("Jane ", "Doe") // Returns "Jane Doe"
strLength

Returns the length of a string.

strLengthDescription
SignaturestrLength(String input)
Parametersinput - String for which to calculate the length.
ReturnsLong - Length of the string.
ExamplestrLength("Jane Doe") // Returns 8
strReplace

Returns a new string, for which string fragments within that string have been replaced by a replacement string. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".

strReplaceDescription
SignaturestrReplace(String input, String toReplace, String replacement)
Parametersinput - String which contains fragments to be replaced.
toReplace - A string that is to be replaced by replacement. Replaces all occurrences.
replacement - The string that replaces the toReplace string.
ReturnsString - Length of the string.
ExamplestrReplace("Quick brown fox.", "brown", "red") // Returns "Quick red fox."
strToLower

Returns the given string value converted to lower case.

strToLowerDescription
SignaturestrToLower(String input)
Parametersinput - String to convert to lower case.
ReturnsString - Provided string converted to lower case.
ExamplestrToLower("I am Small!") // Returns "i am small!"
strToUpper

Returns the given string value converted to upper case.

strToUpperDescription
SignaturestrToUpper(String input)
Parametersinput - String to convert to upper case.
ReturnsString - Provided string converted to upper case.
ExamplestrToUpper("I am large!") // Returns "I AM LARGE!"
strSubstring

Returns a portion of a string, starting at the specified index and extending for a given number of characters afterwards.

strSubstringDescription
SignaturestrSubstring(String input, Long start, Long length)
Parametersinput - String to of which to extract a fragment.
start - The index of the first character to include in the returned substring (zero-based-index).
length - The number of characters to extract.
ReturnsString - A new string containing the specified part of the given string.
ExamplestrSubstring("Quick brown fox.", 6, 6) // Returns "Quick fox."
strEndsWith

Determines whether a string ends with the characters of a specified string, returning true or false as appropriate.

strEndsWithDescription
SignaturestrEndsWith(String input, String suffix)
Parametersinput - String being searched.
suffix - The characters to be searched for at the end of input.
ReturnsBoolean - true if the given characters are found at the end of the string; otherwise, false
ExamplestrEndsWith("Quick brown fox.", "fox.") // Returns true
strStartsWith

Determines whether a string starts with the characters of a specified string, returning true or false as appropriate.

strStartsWithDescription
SignaturestrStartsWith(String input, String prefix)
Parametersinput - String being searched.
prefix - The characters to be searched for at the start of input.
ReturnsBoolean - true if the given characters are found at the start of the string; otherwise, false
ExamplestrStartsWith("Quick brown fox.", "Quick") // Returns true
strExpand

Expands an environment variables which is enclosed in a string, into its underlying value. This environment variable may have been defined in Resource Environment Asset or was defined via on system level.

tip

layline.io is internally using the StringSubstitutor method which provides additional functionality. You can learn more about it here under section "Using Interpolation".

strExpandDescription
SignaturestrExpand(String input)
Parametersinput - String to be expanded.
ReturnsString - Expanded string. See example.
ExampleAssuming thatlay:myEnvionmentVar has been defined as "MyVar" in Resource Environment Asset:
strExpand("This is ${lay:myEnvionmentVar}") // Replaces the environment variable lay:myEnvironmentVar and returns "This is MyVar".
strExpand("${date:yyyy-MM-dd}") // Expands to current date.
strTrimString

Removes leading and trailing whitespace from a string and returns a new string, without modifying the original string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).

If the string to trim represents an empty character sequence, or the first and last characters of character sequence represented by this string both have codes greater than '\u0020' (the space character), then a reference to this string is returned. Otherwise, if there is no character with a code greater than '\u0020' in the string, then a string representing an empty string is returned.

strTrimStringDescription
SignaturestrTrimString(String input)
Parametersinput - String to be trimmed.
ReturnsString - Trimmed string.
ExamplestrTrimString(" Yippieh Ey Yeah ") // Returns "Yippieh Ey Yeah".

Can't find what you are looking for?

Please note, that the creation of the online documentation is Work-In-Progress. It is constantly being updated. should you have questions or suggestions, please don't hesitate to contact us at support@layline.io .