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.
The coort variable can be used to access the Fabasoft Folio Runtime.
The current transaction context is accessible by the cootx variable.
The cooobj variable holds the current object on which the evaluation of the expression is invoked.
For use case implementations in app.ducx expression language, the coometh variable holds the so-called method context.
The coouser variable holds the user object of the current user.
The coogroup variable holds the group object of the role of the current user.
The cooposition variable holds the position object of the role of the current user.
The cooenv variable holds the user environment of the current user.
The cooroot variable holds the desk of the current user.
The coolang variable holds the language of the current user.
The coodomain variable holds the current domain.
The coonow variable holds the current date and time.
// 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.
@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.
The year property can be used for getting and setting the year.
The month property can be used for getting and setting the month.
The day property can be used for getting and setting the day.
The hour property can be used for getting and setting the hour.
The minute property can be used for getting and setting the minutes.
The second property can be used for getting and setting the seconds.
The dayinweek property can be used for getting the day of the week, with the value 0 representing Sunday and 6 representing Saturday.
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).
The weekinyear property can be used for getting the week of the year, with the possible values ranging from 1 to 52.
The local property returns the date and time value converted to local time.
The universal property returns the date and time value converted to universal time.
@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.
The address property can be used to get the unique key of the object.
The identification property can be used to get the key of an object at a given time.
The name property can be used to geht the name of the object without transaction context.
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
@desk = cooroot;
Values of data type CONTENT deliver results of interface functions with fixed paraters for easy access.
The base16 property returns the content as hex encoded string.
The base64 property returns the content as base 64 encoded string.
The content property returns the content string.
The date property returns the modification time.
The file property returns a file with the content with resolving of doc properties.
The hash property returns a hash string of the content.
The id property returns the content id.
The object property returns the associated object.
The rawfile property returns a file with the content without resolving of doc properties.
The size property returns the size in bytes.
Table 44: Implicit CONTENT properties
@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.
IsClass determines whether the object class it is invoked on is derived from or identical to class.
HasClass determines whether the object is an instance of or derived from class.
GetClass returns the object class of the object.
GetName returns the Name (COOSYSTEM@1.1:objname) of the object.
GetAddress returns the Address (COOSYSTEM@1.1:objaddress) of the object.
GetReference returns the Reference (COOSYSTEM@1.1:reference) of a component object.
GetIdentification returns the full identification of the object, which is a combination of the Address (COOSYSTEM@1.1:objaddress) and a version timestamp.
@objectclass = cooobj.GetClass();
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.
// Assuming that the global scope contains a dictionary
The typeof function allows you to determine the data type of an expression. The result is a type or property definition object.
// 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.
The upper function converts all characters of a string to upper case.
The lower function converts all characters of a string to lower case.
The indexof function returns the character-based index of pattern within string. If the pattern is not found the function returns -1
The strlen function returns the length of string.
The strtrim function trims white space at the beginning and at the end of string.
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.
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.
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.
@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”).
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.
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.
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
// 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.
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.
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.
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).
The unique function makes the elements in list unique.
The revert function reverts the elements in list.
insert(@orders, count(@orders), @neworder);
The next table shows the list of mathematical functions supported by app.ducx expression language.
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.
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.
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
@avgorderamount = avg(@customer.APPDUCXSAMPLE@200.200:customerorders.
Table 50 contains a list of supported escape sequences for special characters.
10 or 0x0a
11 or 0x0b
13 or 0x0D
12 or 0x0C
92 or 0x5C
63 or 0x3F
Single quotation mark
39 or 0x27
Double quotation mark
34 or 0x22
hh hhhh hhh
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.
@fullname = "Samuel \"Sam\" Adams";