Interpreter built-in functions

This API page describes built-in functions defined on Interpreter level.

Operators

Operators underneath the Scolvo script are implemented as builtin functions to provide the flexibility of operator overloading with easy setup. The operator references are resolved into function declaration nodes while parsing the tree.

Assignment operator

This is the basic assignment operator. Assignment takes a left value that represent a variable reference and any expression as right side. The following operators are currently supported:

Function syntax:

variable = expression

variable += expression

variable -= expression

variable *= expression

variable /= expression

variable %= expression

variable &= expression

variable |= expression
Example assignments
 1// simple assignment
 2var number = 11;
 3
 4// interpreted as variable = variable + expression
 5number += 1;
 6
 7// interpreted as variable = variable - expression
 8number -= 3;
 9
10// interpreted as variable = variable * expression
11number *= 4;
12
13// interpreted as variable = variable / expression
14number /= 2;
15
16// interpreted as variable = variable % expression
17number %=10;
18
19// interpreted as variable = variable && expression
20number &= 100;
21
22// interpreted as variable = variable || expression
23number |= 100;

Division operator

The simple division (/) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example division
1var number = 11;
2var other = number / 2;

Equals operator

The simple equals (==) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example equals usage
1var number = 11;
2if (number == 11) {
3  info("Equals 11.");
4}

GreaterOrEquals operator

The simple greater or equals (>=) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example greater-or-equals usage
1var number = 11;
2if (number >= 0) {
3  info("It is a positive number.");
4}

GreaterThan operator

The simple greater than (>) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example greather-than usage
1var number = 11;
2if (number > -1) {
3  info("It is a non-negative number.");
4}

LessOrEquals operator

The simple less or equals (<=) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example less-or-equals
1var roomTemperatureLimit = 26;
2if (actualTemperature <= roomTemperatureLimit) {
3  info("The air temperature is fine.");
4}

LessThan operator

The simple less (<) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example less-than
1var boilingTemperature = 100;
2if (waterTemperature < boilingTemperature) {
3  info("It is still liquid.");
4}

Logical operators

The simple logical or and and (|| and && respectively) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example logical operator
1if ((liquidType == "WATER" && liquidTemperature < 100 && liquidTemperature > 0)
2   || (liquidType == "ANTIFREEZE_LIQUID" && liquidTemperature < 129 && liquidTemperature > -37)) {
3  info("It is still liquid.");
4}

Minus operator

The simple subtract (-) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example minus operator
1var number = 10;
2var remaining = number - 2;

Modulus operator

The simple modulus (%) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example modulus operator
1var amount = 100;
2var numOfEmployees = 3;
3var remaining = amount % numOfEmployees;

Multiplication operator

The simple multiplication (*) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example multiplication operator
1var wishAttemptsForOnePerson = 3;
2var numOfEmployees = 3;
3var sumOfWishes = wishAttemptsForOnePerson * numOfEmployees;

Plus operator

The simple addition (+) operator implemented to be fully compatible with it’s definition in most programming and mathematical contexts.

Example plus operator
1var limit = 300;
2var punctuationDelta = 4;
3
4if (actualPoints > limit + delta) {
5  info("It is OK.");
6}

Operator precedence

Here’s the complete table of operator precedence, that is the exact copy of how Java implements it.

String functions

This goup defines the syntax and definition of String related built-in functions.

decimalFormat()

This function returns the formatted String of the given number according to the given decimal format string.

Function syntax

String decimalFormat(number, formatString)

Example decimalFormat() function call
1var number = java.lang.Integer("10");
2var str = decimalFormat(number, "##");

isNumber()

This function checks if the given number Sting is a number or not.

Function syntax

Boolean isNumber(numberString)

Or

Boolean isNumber(numberString, decimalSeparator, groupingSeparator)

where the numberString is given as String and if the the decimal and grouping separators are used, then these should be given as Strings too.

Example isNumber() function call
1var resultInt = isNumber("20");
2var resultDecimal = isNumber("30.5");
3var resultDecimalWithSymbols = isNumber("40 000,5", ",", " ");

parseNumber()

This function converts the given String to number (according to the optionally given format parameters).

Function syntax

Number parseNumber(numberString)

Or

Number parseNumber(numberString, decimalSeparator, groupingSeparator)

where the numberString is given as String and if the the decimal and grouping separators are used, then these should be given as Strings too.

Example parseNumber() function call
1var resultInt = parseNumber("20");
2var resultDecimal = parseNumber("30.5");
3var resultDecimalWithSymbols = parseNumber("40 000,5", ",", " ");

stringFormat()

This function takes the given format pattern String and combines with the given format data parameter.

Function syntax

String stringFormat(formatPattern, formatData)

Or

String stringFormat(formatPattern, formatDataList)

where the formatPattern is given as String and the formatData is given as String, formatDataList list is consists of Strings too.

Example stringFormat() function call
1var stringFormatPattern = "Hello %s!";
2var stringFormatData = "World";
3var formattedString = stringFormat(stringFormatPattern, stringFormatData);
4
5var stringFormatPattern = "Hello %s, Bye %s!";
6var stringFormatFirstData = "World";
7var stringFormatSecondData = "Bye";
8var formattedString = stringFormat(stringFormatPattern, [stringFormatFirstData, stringFormatSecondData]);

Date functions

This goup defines the syntax and definition of Date related built-in functions.

now()

This function returns the system date-time in java.util.Date format.

Function syntax

Date now()

Example now() function call
1var actualDateTime = now();

nowInMillis()

This function returns the system timestamp in java.util.Long format.

Function syntax

Long nowInMillis()

Example nowInMillis() function call
1var timestamp = nowInMillis();

dateToString()

This function transforms the given date or timestamp according to the given format and returns as String. The format string is as described in Java API SimpleDateFormat documentation.

Function syntax

String dateToString(Date or timestamp, “format string”)

Example dateToString() function call
1info("The actual date-time in Hungarian format is: " + dateToString(nowInMillis(), "yyyy.MM.dd. HH:mm"));

parseStringToDate()

This function transforms the given date string according to the given format and returns as java.util.Date. The format string is as described in Java API SimpleDateFormat documentation.

Function syntax

Date parseStringToDate(“Date in string format”, “format string”)

Example parseStringToDate() function call
1var meetingDateString = "2021.04.01 10:10";
2var meetingDate = parseStringToDate(meetingDateString, "yyyy.MM.dd. HH:mm");

dateBefore()

This function checks the two Date or timestamp parameters: it tests if the first date is before the date defined by the second parameter. The result is returned in form of Boolean.

Function syntax

Boolean dateBefore(Date or timestamp as first parameter, Date or timestamp as second parameter)

Example dateBefore() function call
1if (dateBefore(parseStringToDate("2021.04.01 10:10", "yyyy.MM.dd. HH:mm"), now()) {
2  info("You can do whatever you want, you still have time until the meeting.");
3} else {
4  info("Meeting time!");
5}

dateAfter()

This function checks the two Date or timestamp parameters: it tests if the first date is after the date defined by the second parameter. The result is returned in form of Boolean.

Function syntax

Boolean dateAfter(Date or timestamp as first parameter, Date or timestamp as second parameter)

Example dateAfter() function call
1if (dateAfter(parseStringToDate("2021.04.01 10:10", "yyyy.MM.dd. HH:mm"), now()) {
2  info("The meeting is ongoing.");
3} else {
4  info("Prepare for the meeting, you still have time!");
5}

dateSame()

This function checks the two Date or timestamp parameters: it tests if they are the same, where the comparison is according to the unit parameter. The result is returned in form of Boolean.

Valid values of the unit parameter

Value

Comparison

year

true if the year values of the two dates are equal

month

true if the year and month values of the two dates are equal

week

true if the week of year and year values of the two dates are equal

day

true if day of year and year values of the two dates are equal

hour

true if hour of day, day of year and year values of the two dates are equal

minute

true if minute, hour of day,day of year and year values of the two dates are equal

seconds

true if seconds, minute, hour of day, day of year and year values of the two dates are equal

Function syntax

Boolean dateSame(Date or timestamp as first parameter, Date or timestamp as second parameter, unit paramer as String)

Example dateSame() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2if (dateSame(baseDate, now(), "week")) {
3  info("Prepare for the meeting, it is this week!");
4} else {
5  info("You don't have to prepare for the meeiting, it isn't this week.");
6}

dateDifference()

This function calculates the differentce of the two Date or timestamp parameters according to the unit parameter and retuns the absolute value as Integer.

Valid values of the unit parameter

Value

Comparison

year

returns the absolute value of the difference of the year values of the two dates

month

returns the absolute value of the difference of the month values of the two dates considering the years too (2020.12 and 2019.11 results 13)

week

returns the absolute value of the difference of the two dates in days and converted to weeks

day

returns the absolute value of the difference of the two dates in days

hour

returns the absolute value of the difference of the two dates in hours

minute

returns the absolute value of the difference of the two dates in minutes

seconds

true if seconds, minute, hour of day, day of year and year values of the two dates are equal

Function syntax

Integer dateDifference(Date or timestamp as first parameter, Date or timestamp as second parameter, unit paramer as String)

Example dateDifference() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2if (dateDifference(baseDate, now(), "week") == 0) {
3  info("Prepare for the meeting, it is this week!");
4} else {
5  info("You don't have to prepare for the meeiting, it isn't this week.");
6}

dateAdd()

This function adds the given amount (can be any integer) of the given unit to the Date or timestamp parameter and returns it as java.util.Date.

Valid values of the unit parameter

Value

Calculation

year

adds desired times 1 year to the base date

month

adds desired times 1 month to the base date

week

adds desired times 1 week to the base date

day

adds desired times 1 day to the base date

hour

adds desired times 1 hour to the base date

minute

adds desired times 1 minute to the base date

seconds

adds desired times 1 second to the base date

Function syntax

Date dateAdd(Date or timestamp as first parameter, amount as Integer, unit paramer as String)

Example dateAdd() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2info("You have to start meeting preparation at " + dateAdd(baseDate, -7, "day"));

dateSubtract()

This function subtracts the given amount (can be any integer) of the given unit from the Date or timestamp parameter and returns it as java.util.Date.

Valid values of the unit parameter

Value

Calculation

year

substracts desired times 1 year to the base date

month

substracts desired times 1 month to the base date

week

substracts desired times 1 week to the base date

day

substracts desired times 1 day to the base date

hour

substracts desired times 1 hour to the base date

minute

substracts desired times 1 minute to the base date

seconds

substracts desired times 1 second to the base date

Function syntax

Date dateSubtract(Date or timestamp as first parameter, amount as Integer, unit paramer as String)

Example dateSubtract() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2info("You have to start meeting preparation at " + dateSubtract(baseDate, 7, "day"));

firstDay()

This function return the first day calculated based on the given Date or timestamp and on the given unit, and returns the result in form of java.util.Date.

Valid values of the unit parameter

Value

Calculation

year

returns the first day of the year based on the parameter (at time 00:00:00)

month

returns the first day of the month based on the parameter (at time 00:00:00)

week

returns the first day of the week based on the parameter (at time 00:00:00)

Function syntax

Date firstDay(Date or timestamp as first parameter, unit paramer as String)

Example firstDay() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2if (dateAfter(now(), firstDay(baseDate, "week"))) {
3  info("You have to start meeting preparation, it is this week.");
4}

lastDay()

This function return the last day calculated based on the given Date or timestamp and on the given unit, and returns the result in form of java.util.Date.

Valid values of the unit parameter

Value

Calculation

year

returns the last day of the year based on the parameter (at time 00:00:00)

month

returns the last day of the month based on the parameter (at time 00:00:00)

week

returns the last day of the week based on the parameter (at time 00:00:00)

Function syntax

Date lastDay(Date or timestamp as first parameter, unit paramer as String)

Example lastDay() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2if (dateAfter(now(), lastDay(dateSubtract(baseDate, 1, "week"), "week"))) {
3  info("You have to start meeting preparation, it is this week.");
4}

weekOfDate()

This function returns the week number calculated based on the given Date or timestamp and on the given unit, and returns the result as Integer.

Valid values of the unit parameter

Value

Calculation

year

returns the week of year of the given date

month

returns the week of month of the given date

Function syntax

Integer weekOfDate(Date or timestamp as first parameter, unit paramer as String)

Example weekOfDate() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2info("The meeting is on " + weekOfDate(baseDate, "year") + "th week.");

dayOfDate()

This function returns the day number calculated based on the given Date or timestamp and on the given unit, and returns the result as Integer.

Valid values of the unit parameter

Value

Calculation

year

returns the day of year of the given date

month

returns the day of month of the given date

week

returns the day of week of the given date (Sunday is 0)

Function syntax

Integer dayOfDate(Date or timestamp as first parameter, unit paramer as String)

Example dayOfDate() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2info("The meeting is on " + dayOfDate(baseDate, "week") + "th day of the week.");

partOfDate()

This function returns the part of the given Date or timestamp based on the given unit, and returns the result as Integer.

Valid values of the unit parameter

Value

Calculation

year

returns the year of the given date

month

returns the month of the given date (January results 1)

day

returns the day of the month of the given date

hour

returns the hour of the given date

minute

returns the minute of the given date

second

returns the second of the given date

millisecond

returns the millisecond of the given date

Function syntax

Integer partOfDate(Date or timestamp as first parameter, unit paramer as String)

Example partOfDate() function call
1var baseDate = parseStringToDate("2021.04.28 10:10", "yyyy.MM.dd. HH:mm");
2info("The meeting starts at " + partOfDate(baseDate, "hour") + ":" + partOfDate(baseDate, "minute") + ".");

Util functions

This goup defines the syntax and definition of utility built-in functions.

uuid()

This function returns a new random generated Type 4 UUID in form of String.

Function syntax

Date uuid()

Example uuid() function call
1var id = uuid();

toList()

This function returns the received array as List of boxed types.

Function syntax

List<appropriate boxed type> toList(any-type-of-array)

Example toList() function call
1var myBites = toList("one two three".getBytes());;

sendDataChange()

This function sends a data change to the Backend, where the first parameter defines the TypeDefinition (table name) and the second parameter defines the change set in form of array of maps.

Function syntax

void sendDataChange(type definition name, change set)

Example sendDataChange() function call
1var changeSet = [{"changeType":"INSERT", "id":"12345", "other_key": "other value"}];
2sendDataChange("myTypeDefinitionName", changeSet);

Type Definition Extension functions

This goup defines the syntax and definition of Type Definition Extension built-in functions. These functions are helper functions to execute database change sets in the client’s database.

Note

The change set parameter may contain “changeType” key defining the type of the change, but in the below functions the value of this key is not considered (simply skipped).

insertOrReplaceTypeDefinition()

This function executes the change set on the client’s database, if the given id exists, then an UPDATE operation, otherwise an INSERT operation with the given data is executed on the TypeDefinition (table name).

Function syntax

void insertOrReplaceTypeDefinition(type definition name, change set)

Example insertOrReplaceTypeDefinition() function call
1var changeSet = {"changeType":"INSERT", "id":"12345", "other_key": "other value"};
2insertOrReplaceTypeDefinition("myTypeDefinitionName", changeSet);

insertTypeDefinition()

This function executes an INSERT operation with the given data on the client’s database on the TypeDefinition (table name).

Function syntax

void insertTypeDefinition(type definition name, change set)

Example insertTypeDefinition() function call
1var changeSet = {"changeType":"INSERT", "id":"12345", "other_key": "other value"};
2insertTypeDefinition("myTypeDefinitionName", changeSet);

updateTypeDefinition()

This function executes an UPDATE operation with the given data on the client’s database on the TypeDefinition (table name).

Function syntax

void updateTypeDefinition(type definition name, record id as String, change set)

Example updateTypeDefinition() function call
1var changeSet = {"changeType":"UPDATE", "other_key": "other value"};
2updateTypeDefinition("myTypeDefinitionName", "12345", changeSet);

deleteTypeDefinition()

This function executes a DELETE operation with the given id on the client’s database on the TypeDefinition (table name).

Function syntax

void deleteTypeDefinition(type definition name, record id as String)

Example deleteTypeDefinition() function call
1deleteTypeDefinition("myTypeDefinitionName", "12345");

Builder functions

This goup defines the syntax and definition of Builder built-in functions. These functions are helper functions to create event objects manipulating the UI elements. There are two major groups: Target Events modifying the UI elements and Source Events binding listeners to reactive UI elements. Beside these there is a small gorup with functions helping in UI definition. The created event objects are executed using fireEvent(event object, originId as String) built-in function, where the originId parameter is usually the name of the container page. The originId for Traget Events can be any string if the event is created for elements of same page, must be the name of the other page when the targeted item is on different page. The originId for Source Events can be any string.

createTargetEvent()

This function is a base function for the Target Event group, for customization purposes it is available as built-in function too. It creates a Target Event object in form of Map<String, Object> from the given parameters.

Function syntax

Map<String, Object> createTargetEvent(target element id as String, target event type as String, event data in form of Object)

Example createTargetEvent() function call
1var newItem = {
2  "id": "1234",
3  "title": "My new note title",
4  "description": "To have an example item"
5};
6var event = createTargetEvent("NoteList", "onAddItem", newItem);
7fireEvent(event, "NotesPage");

createSourceEvent()

This function is a base function for the Source Event group, for customization purposes it is available as built-in function too. It creates a Source Event object in form of Map<String, Object> from the given parameters. The trigger name parameter is extended by the Interpreter with the “on” prefix, so in the given example a function with name onAddNoteButtonClicked(originId) has to be written.

Function syntax

Map<String, Object> createSourceEvent(source element id as String, source event type as String, trigger name as String)

Example createSourceEvent() function call
1fireEvent(createSourceEvent("AddNoteButton", "onClick", "AddNoteButtonClicked"), "NotesPage");

createSelectOption()

This function is a helper function to create a drop-down list option. It creates an Option object in form of Map<String, Object> based on the given parameters.

Function syntax

Map<String, Object> createSelectOption(id of selected item as String, value describing the option as String, is default option as boolean)

Example createSelectOption() function call
1var options = [
2  createSelectOption("yes", DICTIONARY.yes, true),
3  createSelectOption("no", DICTIONARY.no, false),
4  createSelectOption("maybe", DICTIONARY.maybe, false)
5];

createMultiSelectOption()

This function is a helper function to create a multi-selectable drop-down list option. It creates an Option object in form of Map<String, Object> based on the given parameters.

Function syntax

Map<String, Object> createMultiSelectOption(id of selected item as String, value describing the option as String, isChecked boolean value)

Example createMultiSelectOption() function call
1var acceptableFruitOptions = [
2  createMultiSelectOption("apple", DICTIONARY.apple, true),
3  createMultiSelectOption("pear", DICTIONARY.pear, false),
4  createMultiSelectOption("lemon", DICTIONARY.lemon, false),
5  createMultiSelectOption("melon", DICTIONARY.melon, true),
6];

createShortToastNotificationTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then a toast notification is diplayed on the UI for a short time period (the value is defined by the client type, it is 3 seconds for webapp type).

Function syntax

Map<String, Object> createShortToastNotificationTargetEvent(message to be presented as String)

Example createShortToastNotificationTargetEvent() function call
1fireEvent(createShortToastNotificationTargetEvent("My message content"), "NotesPage");

createAddItemTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then a new item is added the UI element.

Function syntax

Map<String, Object> createAddItemTargetEvent(target element id as String, new item in form of Map<String, Object>)

Example createAddItemTargetEvent() function call
1var event = createAddItemTargetEvent("NoteList", {
2  "id": "1234",
3  "title": "My new note title",
4  "description": "To have an example item"
5});
6fireEvent(event, "NotesPage");

createReplaceItemTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then an existing item (identified by the id) replaced by the new value in the UI element.

Function syntax

Map<String, Object> createReplaceItemTargetEvent(target element id as String, new item value in form of Map<String, Object>)

Example createReplaceItemTargetEvent() function call
1var event = createReplaceItemTargetEvent("NoteList", {
2  "id": "1234",
3  "title": "New value of the title",
4  "description": "New value of the description"
5});
6fireEvent(event, "NotesPage");

createRefreshItemTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the whole item set of the referred UI element is replaced by the items paramter (where the definition of an item is given in form of Map<String, Object>).

Function syntax

Map<String, Object> createRefreshItemTargetEvent(target element id as String, new items as array of item definitions)

Example createRefreshItemTargetEvent() function call
 1var event = createRefreshItemTargetEvent("NoteList", [{
 2    "id": "1",
 3    "title": "Title of the item",
 4    "description": "Description of the item"
 5  },
 6  {
 7    "id": "2",
 8    "title": "Title of the second item",
 9    "description": "Description of the second item"
10  }
11]);
12fireEvent(event, "NotesPage");

createRemoveItemTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then an item is removed from the item set of the referred UI element.

Function syntax

Map<String, Object> createRemoveItemTargetEvent(target element id as String, item id as String)

Example createRemoveItemTargetEvent() function call
1fireEvent(createRemoveItemTargetEvent("NoteList", "1"), "NotesPage");

createValueChangeTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the value of the UI element is set to the given parameter value.

Function syntax

Map<String, Object> createValueChangeTargetEvent(target element id as String, appropriate item value as Object)

Example createValueChangeTargetEvent() function call
1fireEvent(createValueChangeTargetEvent("DescriptionInput", "New value of the text input"), "NotesPage");

createErrorValueChangeTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the error value ( e.g. validation error message) of the UI element is set to the given value.

Function syntax

Map<String, Object> createErrorValueChangeTargetEvent(target element id as String, error description as String)

Example createErrorValueChangeTargetEvent() function call
1fireEvent(createErrorValueChangeTargetEvent("DescriptionInput", "The given value is too long, the maximum enabled lenght is 50."), "NotesPage");

createEnableChangeTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the UI element is set to enabled or disabled according to the given value.

Function syntax

Map<String, Object> createEnableChangeTargetEvent(target element id as String, is enabled as Boolean)

Example createEnableChangeTargetEvent() function call
1fireEvent(createEnableChangeTargetEvent("DescriptionInput", true), "NotesPage");

createVisibilityChangeTargetEvent()

This function is in the Target Event group, it results a Target Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the visibility of the referred UI element is set according to the given value. Valid visibility status values are: “visible”, “gone” and “invisible”, where:

Meaning of values

Value

Description

visible

The UI element is visible

invisible

The UI element is not visible, but he containing space is kept

gone

The UI element is not visible, and the containing space is not kept

Function syntax

Map<String, Object> createVisibilityChangeTargetEvent(target element id as String, visibility status as String)

Example createVisibilityChangeTargetEvent() function call
1fireEvent(createVisibilityChangeTargetEvent("DescriptionInput", "gone"), "NotesPage");

createValueChangeSourceEvent()

This function is in the Source Event group, it results a Source Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the given trigger is bound to value change event of the UI element. The system adds an “on” prefix to the trigger name. In the example below a function with name onDescriptionInputChanged(originId) has to be implemented.

Function syntax

Map<String, Object> createValueChangeSourceEvent(target element id as String, trigger name to be bound as String)

Example createValueChangeSourceEvent() function call
1fireEvent(createValueChangeSourceEvent("DescriptionInput", "DescriptionInputChanged"), "NotesPage");

createSelectionChangeSourceEvent()

This function is in the Source Event group, it results a Source Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the given trigger is bound to selection change event of the UI element (where this event is available). The system adds an “on” prefix to the trigger name. In the example below a function with name onActivityYesNoOptionsInputSelectionChanged(originId) has to be implemented.

Function syntax

Map<String, Object> createSelectionChangeSourceEvent(target element id as String, trigger name to be bound as String)

Example createSelectionChangeSourceEvent() function call
1fireEvent(createSelectionChangeSourceEvent("ActivityYesNoOptionsInput", "ActivityYesNoOptionsInputSelectionChanged"), "NotesPage");

createClickSourceEvent()

This function is in the Source Event group, it results a Source Event object in form of Map<String, Object> based on the given parameters. When this event is fired, then the given trigger is bound to selection clicked event of the UI element (where this event is available). The system adds an “on” prefix to the trigger name. In the example below a function with name onSaveOrderButtonClicked(originId) has to be implemented.

Function syntax

Map<String, Object> createClickSourceEvent(target element id as String, trigger name to be bound as String)

Example createClickSourceEvent() function call
1fireEvent(createClickSourceEvent("SaveOrderButton", "SaveOrderButtonClicked"), "NotesPage");

Math functions

This goup defines the syntax and definition of Math built-in functions. These functions are implementing basic math operations. The Scolvo Script uses two basic types for number values: BigInteger and BigDecimal. If any of the function params is given as BigDecimal then the result is given in BigDecimal format, otherwise the result is given as BigInteger.

abs()

This function returns the absolute value of the given number.

Function syntax

BigInteger abs(value as BigInteger)

or

BigDecimal abs(value as BigDecimal)

Example abs() function call
1var difference = abs(valueOfFirstCalculation - valueOfSecondCalculation);

pow()

This function returns a first parameter raised to the power of the number given in the second parameter. If any of the parameters is given as BigDecimal, then the result is also given as BigDecimal, otherwise it is given as BigInteger.

Function syntax

BigInteger or BigDecimal pow(base as BigInteger or BigDecimal, exponential as BigInteger or BigDecimal)

Example pow() function call
1var amount = 1000;
2var interestRate = 1.1;
3var termInYears = 3;
4var debt = amount * pow(interestRate, termInYears);

min()

This function returns the minimum of the given values. If any of the parameters is given as BigDecimal, then the result is also given as BigDecimal, otherwise it is given as BigInteger.

Function syntax

BigInteger or BigDecimal min(first as BigInteger or BigDecimal, second as BigInteger or BigDecimal)

Example min() function call
1var amount = 1000;
2var termInYears = 3;
3var bestCaseResult = min(calculateDebtOtpBank(amount, termInYears), calculateDebtKAndHBank(amount, termInYears));

max()

This function returns the maximum of the given values. If any of the parameters is given as BigDecimal, then the result is also given as BigDecimal, otherwise it is given as BigInteger.

Function syntax

BigInteger or BigDecimal max(first as BigInteger or BigDecimal, second as BigInteger or BigDecimal)

Example max() function call
1var amount = 1000;
2var termInYears = 3;
3var worstCaseResult = max(calculateDebtOtpBank(amount, termInYears), calculateDebtKAndHBank(amount, termInYears));

sqrt()

This function returns the correctly rounded positive square root of the given value.

Function syntax

BigDecimal sqrt(value as BigInteger or BigDecimal)

Example sqrt() function call
1var result = sqrt(2);

Logger functions

This goup defines the syntax and definition of Logger built-in functions. These functions can be used to log information to the client’s log. Supported levels are: error, warn, info, debug, trace. All functions receive the message parameter as String and there is no return value.

error()

This function logs an error to the client’s log.

Function syntax

void error(message as String)

Example error() function call
1if (value == null) {
2  error("Unsupported value when performing save: " + value);
3}

warn()

This function logs a warning to the client’s log.

Function syntax

void warn(message as String)

Example warn() function call
1if (value != null && value > 500) {
2  warn("The given value is too high: " + value);
3  doSomeCalculation(value);
4}

info()

This function logs an info level message to the client’s log.

Function syntax

void info(message as String)

Example info() function call
1if (value != null) {
2  info("The given value is: " + value);
3  doSomeCalculation(value);
4}

debug()

This function logs a debug level message to the client’s log.

Function syntax

void debug(message as String)

Example debug() function call
1if (value != null) {
2  debug("The given value is: " + value);
3  info("Performing some calculation ...");
4  doSomeCalculation(value);
5}

trace()

This function logs a trace level message to the client’s log.

Function syntax

void trace(message as String)

Example trace() function call
1if (value != null) {
2  var tmpResult = doSomeCalculation(value);
3  trace("The result of the calculation is: " + tmpResult);
4}

ReactiveX functions

This goup defines the syntax and definition of so called ReactiveX functions working mainly in publish-subscribe manner. These functions can be used to send messages for other components. These components are specific components of the Clients.

publish()

This function broadcasts a message, and the subscribed components receive this message to handle. The message can be any kind of Object. This function is available for customization purposes, all known usage is implemented in specific built-in functions (the given example is supported by sendDataChange() built-in function).

Function syntax

void publish(message as Object)

Example publish() function call
1var dataChangeMsg = com.scolvo.core.vm.action.rq.DataChangeRq(uuid());
2dataChangeMsg.setTypeDefinition("notes");
3dataChangeMsg.setTypeDefinitionVersion(nowInMillis());
4dataChangeMsg.setChangeset([{"id": "1", "title": "actual title","description": "Actual description", "changeType": "INSERT"}]);
5publish(dataChangeMsg);

trigger()

This function broadcast a TriggerScript object, where the trigger name is given in form of String. As a result the Interpreter executes the function with the given name. This function is available for customization purposes.

Function syntax

void trigger(trigger name as String)

Example trigger() function call
1trigger("NoteSaveButtonClicked");

fireEvent()

This function fires an event given as Map<String, Object>.

Function syntax

void fireEvent(event map as Map<String, Object>, originId as String)

Example fireEvent() function call
1 var event = createReplaceItemTargetEvent("NoteList", {
2  "id": "1234",
3  "title": "New value of the title",
4  "description": "New value of the description"
5});
6fireEvent(event, "NotesPage");

display()

This function displays a page (see Page element) on the UI. The function can be invoked with 3 and 4 parameters too.

Function syntax

void display(page as Page object, page data as Map<String, Object>, originId as String)

or

void display(page as Page object, page data as Map<String, Object>, originId as String, page actions as array of actions)

Example display() function call
1if (pageActions == null) {
2  display(NotesPage, {}, originId);
3} else {
4  display(NotesPage, {}, originId, pageActions);
5}

displayFragment()

This function displays a fragment in a fragment container of the UI. The function can be invoked with 4 and 5 parameters too.

Function syntax

void displayFragment(fragment container name as String, fragment as Fragment object, fragment data as Map<String, Object>, originId as String)

or

void displayFragment(fragment container name as String, fragment as Fragment object, fragment data as Map<String, Object>, originId as String, fragment actions as array of actions)

Example displayFragment() function call
1if (type == "note") {
2  displayFragment("DetailsFragmentContainer", NoteDetailsFragment, {}, originId);
3} else {
4  displayFragment("DetailsFragmentContainer", ItemDetailsFragment, {}, originId, []);
5}

finishPage()

This function closes a Page and removes it from page history.

Function syntax

void finishPage(page name as String, originId as String)

Example finishPage() function call
1 finishPage("NoteDetailsPage", originId);

QueryBuilder functions

This goup defines the syntax and definition of usages of QueryBuilder functionality working with client’s database. There are two kind of methods: chaining methods and termination methods. The chanining methods create or changes a QueryBuilder instance, the termination methods are using or mofifying the QueryBuilder (executes the query on the database or calculates something from the QueryBuilder object).

insert()

This function is a chanining function, it creates a QueryBuilder object with INSERT query type.

Function syntax

QueryBuilder insert()

Example insert() function call
1var insertUserQuery = insert().from("note");
2insertUserQuery.set("id", uuid());
3insertUserQuery.set("title", "New title");
4insertUserQuery.set("content", "New content");
5insertUserQuery.execute();

Note

When inserting to the database it is simpler to use insertTypeDefinition() built-in function.

insertOrReplace()

This function is a chanining function, it creates a QueryBuilder object with insertOrReplace query type (REPLACE INTO database operation). It is usually used when client receives data change from Backend, where the originator can be the client itself. In this case an insert function can fail, but an insertOrReplace is successfull anyway.

Function syntax

QueryBuilder insertOrReplace()

Example insertOrReplace() function call
1var userQuery = insertOrReplace().from("note");
2userQuery.set("id", "735cda84-330a-11ec-8d3d-0242ac130003");
3userQuery.set("title", "New title");
4userQuery.set("content", "New content");
5userQuery.execute();

Note

When executing insert-or-replace operation to the database it is simpler to use insertOrReplaceTypeDefinition() built-in function.

select()

This function is a chanining function, it creates a QueryBuilder object with select query type (SELECT database operation with support of JOIN, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT). It is usually used when rows are selected from client database.

Function syntax

QueryBuilder select()

Example select() function call
1var noteDaos = select()
2  .from("note")
3  .orderBy("title", "asc")
4  .execute();

selectDistinct()

This function is a chanining function, it creates a QueryBuilder object with select distinct query type (SELECT DISTINCT database operation with support of JOIN, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT). It is usually used when rows are selected from client database and we don’t want to have column value combination repeated.

Function syntax

QueryBuilder selectDistinct()

Example selectDistinct() function call where we want to have the title list of notes
1var noteDaos = selectDistinct()
2  .selectAs("note.title", "title")
3  .from("note")
4  .orderBy("title", "asc")
5  .execute();

update()

This function is a chanining function, it creates a QueryBuilder object with update query type (UPDATE database operation). It is used when data has to be updated in the client database.

Function syntax

QueryBuilder update()

Example update() function call
1var updateQuery = update().from("note");
2updateQuery.set("title", "New title with change");
3updateQuery.set("content", "Content change");
4updateQuery.where(eq("id", "735cda84-330a-11ec-8d3d-0242ac130003"));
5updateQuery.execute();

Note

When executing update operation to the database it is easier to use updateTypeDefinition() built-in function.

delete()

This function is a chanining function, it creates a QueryBuilder object with delete query type (DELETE database operation). It is used when data has to be removed from the client database.

Function syntax

QueryBuilder delete()

Example delete() function call
1var deleteQuery = delete().from("note");
2deleteQuery.where(eq("id", "735cda84-330a-11ec-8d3d-0242ac130003"));
3deleteQuery.execute();

Note

When executing delete operation it is easier to use deleteTypeDefinition() built-in function.

from() chaining function

This function is a chanining function, it adds the table name to the QueryBuilder.

Function syntax

QueryBuilder <query-builder-instance>.from(tableName or select defining a table)

Example from() function call
1var deleteQuery = delete().from("note");
2deleteQuery.where(eq("id", "735cda84-330a-11ec-8d3d-0242ac130003"));
3deleteQuery.execute();

fromAs() chaining function

This function is a chanining function, it adds the table name with specific name (as) to the QueryBuilder.

Function syntax

QueryBuilder <query-builder-instance>.fromAs(tableName or select defining a table, name in query)

Example fromAs() function call
1var noteDaos = selectDistinct()
2  .selectAs("noteTitles.title", "title")
3  .fromAs("note", "noteTitles")
4  .orderBy("title", "asc")
5  .execute();

select(columns) chaining function

This function is a chanining function, it adds columns to the column list of the QueryBuilder.

Function syntax

QueryBuilder <query-builder-instance>.select(<columns>)

Where columns is one or more column name.

Example select(columns) function call
1var noteDaos = select()
2  .select("noteTitles.title", "noteTitles.content")
3  .from("note")
4  .orderBy("title", "asc")
5  .execute();

selectAs(column) chaining function

This function is a chanining function, it adds a column to the column list of the QueryBuilder.

Function syntax

QueryBuilder <query-builder-instance>.selectAs(columnName)

Or

QueryBuilder <query-builder-instance>.selectAs(columnName, aliasName)

Where column is a String, and if aliasName is given, then the column is added with alias.

Example selectAs(column) function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .orderBy("noteName", "asc")
5  .execute();

table(tableName) function

This function creates a Table oject with name and optionally with alias, the toString() function creates the “tableName” or “tableName alias” String.

Function syntax

Table table(tableName)

Or

Table table(tableName, alias)

Where tableName is a String, and if aliasName is given, then Table is created with the given alias.

Example table() function call
1var noteTable = table("note");

and() function

This function creates a logical AND criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria and(criterion …)

Where Criterion can be any criterion (e.g.: eq(), lt(), gt(), like(), between, custom(), etc. …), and there can be two or more criterion defined.

Example and() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(and(eq("note.id", "1234"), like("note.title", "%my%")))
5  .orderBy("noteName", "asc")
6  .execute();

or() function

This function creates a logical OR criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria or(criterion …)

Where Criterion can be any criterion (e.g.: eq(), lt(), gt(), like(), between, custom(), etc. …), and there can be two or more criterion defined.

Example or() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(or(eq("note.id", "1234"), eq("note.id", "4321")))
5  .orderBy("noteName", "asc")
6  .execute();

not() function

This function creates a logical NOT criteria with the given parameter what can be used in other QueryBuilder functions.

Function syntax

Criteria not(criteria)

Where the given Critera can be any criteria (e.g.: eq(), lt(), gt(), like(), between, custom(), etc. …).

Example not() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(not(eq("note.id", "1234")))
5  .orderBy("noteName", "asc")
6  .execute();

eq() function

This function creates an equals criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria eq(columnName, columnValue)

Where the given columnName can be any String and columnValue is given as Object. The null columnValue is transformed to “NULL” literal.

Example eq() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(eq("note.id", "1234"))
5  .orderBy("noteName", "asc")
6  .execute();

notEq() function

This function creates a not equals criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria notEq(columnName, columnValue)

Where the given columnName can be any String and columnValue is given as Object. The null columnValue is transformed to “NULL” literal.

Example notEq() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(notEq("note.id", null))
5  .orderBy("noteName", "asc")
6  .execute();

gt() function

This function creates a greater than (‘>’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria gt(columnName, numberValue)

Where the given columnName can be any String and numberValue is given as number.

Example gt() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(gt("note.createdAt", 1635843760000))
5  .orderBy("noteName", "asc")
6  .execute();

gEq() function

This function creates a greater than or equals (‘>=’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria gEq(columnName, numberValue)

Where the given columnName can be any String and numberValue is given as number.

Example gEq() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(gEq("note.createdAt", 1635843760000))
5  .orderBy("noteName", "asc")
6  .execute();

lt() function

This function creates a less than (‘<’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria lt(columnName, numberValue)

Where the given columnName can be any String and numberValue is given as number.

Example lt() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(lt("note.createdAt", 1635843760000))
5  .orderBy("noteName", "asc")
6  .execute();

lEq() function

This function creates a less than or equals (‘<=’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria lEq(columnName, numberValue)

Where the given columnName can be any String and numberValue is given as number.

Example lEq() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(lEq("note.createdAt", 1635843760000))
5  .orderBy("noteName", "asc")
6  .execute();

like() function

This function creates a like (‘LIKE’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria like(columnName, columnValue)

Where the given columnName can be any String and columnValue is given as Object.

Example like() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(like("note.title", "%my%"))
5  .orderBy("noteName", "asc")
6  .execute();

notLike() function

This function creates a not like (‘NOT LIKE’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria notLike(columnName, columnValue)

Where the given columnName can be any String and columnValue is given as Object.

Example notLike() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(notLike("note.title", "%excluded%"))
5  .orderBy("noteName", "asc")
6  .execute();

in() function

This function creates an in (‘IN’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria in(columnName, inValue)

Where the given columnName can be any String and inValue is given as Object and later converted to String.

Example in() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(in("note.title", "('My title1', 'My title2')"))
5  .orderBy("noteName", "asc")
6  .execute();

notIn() function

This function creates a not in (‘NOT IN’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria notIn(columnName, inValue)

Where the given columnName can be any String and inValue is given as Object and later converted to String.

Example notIn() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(notIn("note.title", "('excluded1', 'excluded2')"))
5  .orderBy("noteName", "asc")
6  .execute();

between() function

This function creates a between (‘BETWEEN’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria between(columnName, columnValue1, columnValue2)

Where the given columnName can be any String and columnValue1 and columnValue2 are given as Objects.

Example between() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(between("note.createdAt", 1635843460000, 1635843760000))
5  .orderBy("noteName", "asc")
6  .execute();

notBetween() function

This function creates a not between (‘NOT BETWEEN’) criteria with the given parameters what can be used in other QueryBuilder functions.

Function syntax

Criteria notBetween(columnName, columnValue1, columnValue2)

Where the given columnName can be any String and columnValue1 and columnValue2 are given as Objects.

Example notBetween() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(notBetween("note.createdAt", 1635843460000, 1635843760000))
5  .orderBy("noteName", "asc")
6  .execute();

custom() function

This function creates a custom criteria with the given parameter what can be used in other QueryBuilder functions.

Function syntax

Criteria custom(customExpression)

Where the given customExpression is given as String.

Example notBetween() function call
1var noteDaos = select()
2  .selectAs("note.title", "noteName")
3  .from("note")
4  .where(custom("note.createdAt > 1635843460000 AND note.createdAt < 1635843760000"))
5  .orderBy("noteName", "asc")
6  .execute();