The app.ducx expression language provides you with a set of predefined variables and functions to make programming as convenient as possible.
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 // Accessing transaction variables using the generic interface // Using the current object // Using the method context to call the super method |
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!"; |
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; @closed = @currentdate.dayinweek == 0; |
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; |
Values of data type CONTENT deliver results of interface functions with fixed paraters for easy access.
Property | Description | Function |
base16 | The base16 property returns the content as hex encoded string. | GetContent(…COOGC_BASE16…) |
base64 | The base64 property returns the content as base 64 encoded string. | GetContent(…COOGC_BASE64…) |
content | The content property returns the content string. | GetContent(…COOGC_MULTIBYTEFILE|COOGC_UTF8 …) |
date | The date property returns the modification time. | GetDate() |
file | The file property returns a file with the content with resolving of doc properties. | GetFile() |
hash | The hash property returns a hash string of the content. | GetHash() |
id | The id property returns the content id. | GetID() |
object | The object property returns the associated object. | |
rawfile | The rawfile property returns a file with the content without resolving of doc properties. | GetFile() |
size | The size property returns the size in bytes. | GetSize() |
Table 44: Implicit CONTENT properties
Example |
@mycont = content("Hello world!"); |
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!").
Table 45 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 45: Implicit pseudo functions
Example |
@objectclass = cooobj.GetClass(); cooobj.HasClass(#APPDUCXSAMPLE@200.200:Order) ? |
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.
The typeof function allows you to determine the data type of an expression. The result is a type or property definition object.
Example |
// Determining the data type of the local scope // Determining the data type of the global scope // Determining the data type of a variable // Determining the data type of an expression |
Table 46 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. |
Example |
@value = strhead("ABC", 1); // yields "A" |
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 47: Actions for manipulating strings
Example |
// Get the modification date of the object as formatted string // Format an integer value with leading zeroes to yield "000123" // Format an integer value using digit grouping to yield "123,456" // Get the object's name and subject as formatted string // Assuming that StrCustomFormat is a string object containing the format pattern |
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). |
unique(list) | The unique function makes the elements in list unique. |
revert(list) | The revert function reverts the elements in list. |
Example |
insert(@orders, count(@orders), @neworder); |
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. |
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 49: Mathematical functions
Example |
@avgorderamount = avg(@customer.APPDUCXSAMPLE@200.200:customerorders. |
Additional mathematical functions are provided by the #Math object. For further information, see https://help.appducx.fabasoft.com/index.php?topic=doc/Reference-Documentation/CLASS_FSCEXPEXT_1_1001_MathFunctions.htm.
Table 50 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 | \" |
Hexadecimal number | hh | \xhh | |
Null character | NUL | 0 | \0 |
Unicode character | hhhh | \uhhhh | |
Unicode sequence | hh hhhh hhh | \u{hh,hhhh,hhh} |
Table 50: Escape sequences for special characters
Note: Please be aware that strings in expressions are UTF-8. If you use hexadecimal escape sequences be sure that the resulting byte sequence is a valid UTF-8 character.
Example |
@fullname = "Samuel \"Sam\" Adams"; |