2017 June Release

Predefined variables and functionsPermanent link for this heading

The app.ducx expression language provides you with a set of predefined variables and functions to make programming as convenient as possible.

Predefined variablesPermanent link for this heading

Table 41 shows the list of predefined variables that are provided automatically by the Fabasoft Folio Kernel when an expression is evaluated.

Variable

Description

coort

The coort variable can be used to access the Fabasoft Folio Runtime.

cootx

The current transaction context is accessible by the cootx variable.

cooobj

The cooobj variable holds the current object on which the evaluation of the expression is invoked.

coometh

For use case implementations in app.ducx expression language, the coometh variable holds the so-called method context.

coouser

The coouser variable holds the user object of the current user.

coogroup

The coogroup variable holds the group object of the role of the current user.

cooposition

The cooposition variable holds the position object of the role of the current user.

cooenv

The cooenv variable holds the user environment of the current user.

cooroot

The cooroot variable holds the desk of the current user.

coolang

The coolang variable holds the language of the current user.

coodomain

The coodomain variable holds the current domain.

coonow

The coonow variable holds the current date and time.

Table 41: Predefined variables

Example

// Using the Fabasoft Folio Runtime
User @user = coort.GetCurrentUser(); // or coouser
object @desk = coort.GetCurrentUserRoot();// or cooroot
datetime @currentdate = coonow;

// Accessing transaction variables using the generic interface
cootx.SetVariableValue(#APPDUCXSAMPLE@200.200, 1, #BOOLEAN, 0, true);
boolean @txvarval = cootx.GetVariableValue(#APPDUCXSAMPLE@200.200, 1);

// Using the current object
string @name = cooobj.GetName(cootx);
ObjectClass @objcls = cooobj.GetClass();
Object[] @orders = cooobj.APPDUCXSAMPLE@200.200:customerorders;

// Using the method context to call the super method
cooobj.CallMethod(cootx, coometh);

Implicit properties of the STRING data typePermanent link for this heading

Values of data type STRING currently only support the implicit property length, which returns the length of the string in characters.

Example

@mystr = "Hello world!";
@mystrlen = @mystr.length;

Implicit properties of the DATETIME data typePermanent link for this heading

Values of data type DATETIME expose implicit properties that can be used to access the individual date and time components. These implicit properties are listed in the next table. All of these implicit properties are of data type INTEGER.

Property

Description

year

The year property can be used for getting and setting the year.

month

The month property can be used for getting and setting the month.

day

The day property can be used for getting and setting the day.

hour

The hour property can be used for getting and setting the hour.

minute

The minute property can be used for getting and setting the minutes.

second

The second property can be used for getting and setting the seconds.

dayinweek

The dayinweek property can be used for getting the day of the week, with the value 0 representing Sunday and 6 representing Saturday.

dayinyear

The dayinyear property can be used for getting the day of the year, with the possible values ranging from 1 to 366 (for a leap year).

weekinyear

The weekinyear property can be used for getting the week of the year, with the possible values ranging from 1 to 52.

local

The local property returns the date and time value converted to local time.

universal

The universal property returns the date and time value converted to universal time.

Table 42: Implicit DATETIME properties

Example

@currentdate = coonow;
@currentdate.hour = 12;
@currentdate.minute = 0;
@currentdate.second = 0;

@closed = @currentdate.dayinweek == 0;

Implicit properties of the OBJECT data typePermanent link for this heading

Values of data type OBJECT expose implicit properties that can be used to access some aspects of the object.

Property

Description

address

The address property can be used to get the unique key of the object.

identification

The identification property can be used to get the key of an object at a given time.

name

The name property can be used to geht the name of the object without transaction context.

reference

The reference property can be used to get the reference of an object. This property is only defined for objects of classes derived from ComponentObject.

Table 43: Implicit OBJECT properties

Example

@desk = cooroot;
string @addr = @desk.address;

Implicit properties of the CONTENT data typePermanent link for this heading

Values of data type CONTENT currently only support the implicit property size, which returns the size of the content in bytes.

Example

@mycont = content("Hello world!");
@mycontsize = @mycont.size;

Note: When converting a STRING to a CONTENT as in the example above, be aware that this conversion also includes an UTF-8 byte order mark (BOM). Therefore the value @mycontsize is 15 (3 from the BOM and 12 from "Hello world!").

Implicit pseudo functionsPermanent link for this heading

Table 44 contains a list of implicit pseudo functions supported by app.ducx expression language. These functions can be invoked on an object.

Function

Description

IsClass(class)

IsClass determines whether the object class it is invoked on is derived from or identical to class.

HasClass(class)

HasClass determines whether the object is an instance of or derived from class.

GetClass()

GetClass returns the object class of the object.

GetName(tx)

GetName returns the Name (COOSYSTEM@1.1:objname) of the object.

GetAddress()

GetAddress returns the Address (COOSYSTEM@1.1:objaddress) of the object.

GetReference()

GetReference returns the Reference (COOSYSTEM@1.1:reference) of a component object.

GetIdentification()

GetIdentification returns the full identification of the object, which is a combination of the Address (COOSYSTEM@1.1:objaddress) and a version timestamp.

Table 44: Implicit pseudo functions

Example

@objectclass = cooobj.GetClass();
@objectname = cooobj.GetName(cootx);
@objectaddress = cooobj.GetAddress();

cooobj.HasClass(#APPDUCXSAMPLE@200.200:Order) ?
  cooobj.APPDUCXSAMPLE@200.200:ProcessOrder() : null;

Working with contents and dictionariesPermanent link for this heading

Please refer to chapter “Working with contents” for a list of methods that can be invoked on variables of type CONTENT, and to chapter “Working with dictionaries” for a list of methods that can be invoked on variables of type DICTIONARY.

Example

// Assuming that the global scope contains a dictionary
if (::HasEntry("description")) {
  // Initialize a new content
  content @description = {};
  // Set the string contained in ::description into the content
  // (use 65001 as "codepage" for UTF-8 encoding)
  @description.SetContent(cootx, 1, 65001, ::description);
  // Remove the description string from the global scope dictionary
  ::ClearEntry("description");
}

Getting the data type of an expressionPermanent link for this heading

The typeof function allows you to determine the data type of an expression.

Example

// Determining the data type of the local scope
@localtype = typeof(this);

// Determining the data type of the global scope
@globaltype = typeof(::this);

// Determining the data type of a variable
@myvalue = "Hello world!";
@resulttype = typeof(@myvalue);

// Determining the data type of an expression
@resulttype = typeof(cooobj.APPDUCXSAMPLE@200.200:customerorders);

String functionsPermanent link for this heading

Table 45 contains the list of string utility functions.

Function

Description

upper(string)

The upper function converts all characters of a string to upper case.

lower(string)

The lower function converts all characters of a string to lower case.

indexof(string, pattern)

The indexof function returns the character-based index of pattern within string. If the pattern is not found the function returns -1

strlen(string)

The strlen function returns the length of string.

strtrim(string)

The strtrim function trims white space at the beginning and at the end of string.

strhead(string, index)

The strhead function extracts the leftmost index characters from a string and returns the extracted substring. index is zero-based. If a negative value is supplied in index, absolute value of index is substracted from the length of the string. If the absolute value of a negative index is larger than the length of the string, 0 is used for index.

strtail(string, index)

The strtail function extracts the characters from a string starting at the position specified by index and returns the extracted substring. index is zero-based. If a negative value is supplied in index, the absolute value of index is substracted from the length of the string. If the absolute value of a negative index is larger than the length of the string, 0 is used for index.

strsplit(string, separator)

The strsplit function identifies the substrings in string that are delimited by separator, and returns a list containing the individual substrings.

strjoin(list [, separator])

The strjoin function concatenates the list of strings and inserts separator between the individual elements yielding a single concatenated string. If separator is not specified or null then the list elements are concatenated directly.

strreplace(string, from [, to])

The strreplace function replaces all occurrences of string from with string to in string. If to is not specified or null then all occurences of from are deleted from the string.

Table 45: String functions

Example

@value = strhead("ABC", 1);                    // yields "A"
@value = strtail("ABC", 1);                    // yields "BC"
@value = strsplit("ABC", "B");                 // yields ["A","C"]
@value = strjoin(["A", "B", "C"], "");         // yields "ABC"
@value = strjoin(strsplit("A-B-C", "-"), "+"); // yields "A+B+C"
@value = strreplace("ABC", "B", "");           // yields "AC"
@value = strreplace("ABCABC", "B", "X");       // yields "AXCAXC"
@value = strlen("ABC");                        // yields 3


In addition to the string functions provided by app.ducx expression language, the actions listed in the next table are useful for manipulating strings. For further information, refer to the Fabasoft reference documentation (see chapter “Fabasoft reference documentation”).

Function

Description

COOSYSTEM@1.1:Format(value, pattern, symbols, result)

This action takes a single value (any type) as first parameter and a formatting pattern as second parameter.

The third parameter is for advanced options (code page, custom symbols for separators or the decimal point).

The result is returned in the fourth parameter.

Refer to the Fabasoft reference documentation for a description of the supported formatting patterns.

COOSYSTEM@1.1:Print(string, ...)

Processes a format string or prints the object to a resulting string.

If the string parameter contains a non-empty format string, this is used regardless of the object of the action.

If the object is a string object, the property Print COOSYSTEM@1.1:string is used as format string.

If the object is an error message, the property COOSYSTEM@1.1:errtext is used as format string.

In all other cases the name of the object is used as format string.

If the string contains formatting patterns starting with the "%" character these patterns are replaced by the additional parameters of the Print action.

Refer to the Fabasoft reference documentation for a description of the supported formatting patterns.

COOSYSTEM@1.1:PrintEx(string, arguments)

Uses COOSYSTEM@1.1:Print to print a format string or an object to a resulting string. Parameters for formatting are passed in a string list in the parameter arguments.

Each line in the string list in the arguments parameter is evaluated as an expression.

Table 46: Actions for manipulating strings

Example

// Get the modification date of the object as formatted string
string @formattedstr = cooobj.Format(cooobj.objmodifiedat, "dT");

// Format an integer value with leading zeroes to yield "000123"
integer @intval = 123;
string @intvalstr = cooobj.Format(@intval, "000000");

// Format an integer value using digit grouping to yield "123,456"
integer @intval2 = 123456;
string @intvalstr2 = cooobj.Format(@intval2, "#,###");

// Get the object's name and subject as formatted string
string @titlestr = cooobj.Print("%s (%s)", cooobj.objname, cooobj.objsubject);

// Assuming that StrCustomFormat is a string object containing the format pattern
// "%s iteration %03d", the following expression will write the name of the current object

// and the current loop iteration number padded with leading zeroes to the tracer

for (integer @idx = 0; @idx < 1000; @idx++) {
  %%TRACE(#StrCustomFormat.Print(null, cooobj.objname, @idx));
}

List functionsPermanent link for this heading

The next table shows the list of functions provided for working with lists.

Function

Description

count(list)

The count function returns the number of elements in list.

Note: Do not use count(list) > 0 or count(list) == 0 to check whether a list is full or emty. Use the boolean type cast list or !list instead, this is much more efficient.

insert(list, index, value)

The insert function inserts value into list at position index. The parameter list is modified by that function, therefore it must be assignable. index is zero-based. If a negative value is supplied in index, absolute value of index is substracted from the length of the list. If the absolute value of a negative index is larger than the length of the list, 0 is used for index. If index is greater than the number of elements in list, value is appended at the end of list.

delete(list, index [, count])

The delete function deletes the value at index from list. The parameter list is modified by that function, therefore it must be assignable. index is zero-based. If a negative value is supplied in index, absolute value of index is substracted from the length of the list. If the absolute value of a negative index is larger than the length of the list, 0 is used for index. If count is not specified or null then one element is deleted, otherwise count specifies the number of elements following index that should be deleted. If less than count elements are available, the list is truncated at index. If count is negative, the elements before index are deleted.

find(list, value)

The find function searches list for the element value, and returns the index of the first occurrence within the entire list. If value is not found in list, the number of elements in list is returned.

sort(list)

The sort function sorts the elements in list. Lists of contents, dictionary or interfaces cannot be sorted. Lists of aggregates can only be sorted, if the aggregate type defines a compare action in COOSYSTEM@1.1:typecompare. Lists of objects are sorted by a defined internal order. This makes sort useful in combination with the unique function, since sort(unique(objlist)) is much faster than unique(objlist).
When sorting aggregates, all properties of COOSYSTEM@1.1:typesortattrs are used for comparing in the listed order. If the aggregate contains additional properties in COOSYSTEM@1.1:typecompattrs, these properties are used as well. If the aggregate has no COOSYSTEM@1.1:typesortattrs, only the properties of COOSYSTEM@1.1:typecompattrs are used. Elements of type COOSYSTEM@1.1:CONTENT or COOSYSTEM@1.1:COMINTERFACE cannot be sorted or compared.

unique(list)

The unique function makes the elements in list unique.

revert(list)

The revert function reverts the elements in list.

Table 47: List functions

Example

insert(@orders, count(@orders), @neworder);
delete(@orders, find(@orders, @canceledorder));
unique(sort(@orders));

Mathematical functionsPermanent link for this heading

The next table shows the list of mathematical functions supported by app.ducx expression language.

Function

Description

sum(list)

The sum function returns the sum of all values in list. Values can also be passed to sum as individual arguments. The sum function can only be used with numeric data types.

avg(list)

The avg function returns the average of all values in list. Values can also be passed to avg as individual arguments. The avg function can only be used with numeric data types.

min(list)

The min function returns the smallest value in list. Values can also be passed to min as individual arguments. The min function can be used with strings and numeric data types.

max(list)

The max function returns the largest value in list. Values can also be passed to max as individual arguments. The max function can be used with strings and numeric data types.

Table 48: Mathematical functions

Example

@avgorderamount = avg(@customer.APPDUCXSAMPLE@200.200:customerorders.
APPDUCXSAMPLE@200.200:ordertotal.currvalue);

Escape sequences for special charactersPermanent link for this heading

Table 49 contains a list of supported escape sequences for special characters.

Character

ASCII representation

ASCII value

Escape sequence

New line

NL (LF)

10 or 0x0a

\n

Horizontal tab

HT

9

\t

Vertical tab

VT

11 or 0x0b

\v

Backspace

BS

8

\b

Carriage return

CR

13 or 0x0D

\r

Form feed

FF

12 or 0x0C

\f

Alert

BEL

7

\a

Backslash

\

92 or 0x5C

\\

Question mark

?

63 or 0x3F

\?

Single quotation mark

'

39 or 0x27

\'

Double quotation mark

"

34 or 0x22

\"

Octal number

ooo

\ooo

Hexadecimal number

hh

\xhh

Null character

NUL

0

\0

Table 49: Escape sequences for special characters

Note: Please be aware that strings in expressions are UTF-8. If you use octal or hexadecimal escape sequences be sure that the resulting byte sequence is a valid UTF-8 character.

Example

@fullname = "Samuel \"Sam\" Adams";