Theory

ADOxx Development Language: EXPRESSION

Expressions provide a basic set of functions and operators for investigating or calculating within a model context and across multiple models. This can be both a fixed calculation and the processing of attribute values. The syntax of the language for EXPRESSION attributes is based on the following grammar:

 

ExprDefinition :                 

  EXPR type: ResultType [ format: FormatString ]

  expr:fixed:CoreExpression .

ResultType :

  double | integer | string | time .

 

Each definition of the EXPRESSION attribute starts with the keyword EXPR. The result type will be fixed by means of the attribute type: and a standard formula expr. Each time an instance is created (object, model or connector) the formula will be used to calculate the result value of the expression.

By setting the modifier as ‘fixed:' the expression will be unchangeable in the Modelling Toolkit. It means that the EXPRESSION attribute evaluates the same formula everywhere.

In the expressions where you can change the instances, each evaluation instance will be assigned to an appropriate expression. Then the specification of an expression in the "Expression-Definition" is optional and is of use for initial assignment of an expression to evaluation instances. For each evaluation instance, you can open an input window from the ADOxx Notebook, which enables the editing of the expression. The changeable expression will be saved to the evaluation instance under expr.

In ADOxx, three different types of expressions can be found:

  • LeoExpressions LeoExpressions are a set of basic functions and operators, from which an expression can be aggregated. They are used to calculate values, manipulate strings and perform other similar basic tasks. LeoExpressions can be used with every LEO language. Wherever LEO strings are possible, LEO expressions can be used.
  • CoreExpressions: A CoreExpression is an ADOxx-specific extension of a LeoExpression. When creating a CoreExpression, both functions and operators of LeoExpressions and core-specific functions designed specifically for ADOxx can be utilised. CoreExpressions can only be used in attributes of type EXPRESSIONS.
  • AdoScriptExpressions: An AdoScriptExpression is an extension of a LeoExpression. Consequently, all functions and operators of the LeoExpressions can be used here as well. Furthermore, specifically designed AdoScript functions can be utilised. AdoScriptExpressions can only be used within AdoScript in the ADOxx Development Toolkit.

Leo Expressions

Operators

Logical

AND, OR, NOT

Boolean expressions

Comparison

< > <= >= = <> !=

Greater, less, equal, not equal

Arithmetic

+ - * / - (unary)

 

String

s + t

Concatenation of strings s and t

n * s

Replication: replicate string s n times

s / t

Number of occurrences of string t in string s

s SUB i

i-th character in string s

LEN s

Length of string s in characters

Conversion

STR val

Returns string-representation of value val.

VAL str

Returns value represented by string str.

CMS measure

PTS measure

Convert measure (in cm or points) to real value (e.g. CMS 3.5cm —> 3.5).

CM real

PT real

Convert real value to measure (in cm or points; e.g. CM 3.5 —> 3.5cm).

uistr( val, n)

Convert real value to international string format using n digits.

uival( str )

Convert international number format string-representation to a real value.

Sequence

,

The comma-operator is used to define a sequence of expressions. The final result of the total expression is the value of the last expression.

 

 

Functions

Arithmetic

abs(x)

max(x, y) min(x, y)

pow(x, y) sqrt(x)

exp(x)

log(x)    log10(x)

Arithmetic functions

sin(x) cos(x) tan(x)

asin(x) acos(x) atan(x)

sinh(x) cosh(x) tanh(x)

Trigonometrical functions

random()

Random number

0 >= n < 1

round(x)

Rounds up, if fractional part is >= 0.5

floor(x) ceil(x)

Round up or down, resp.

String

search(source, pattern, start)

Search pattern in source beginning at start (0-based), returns –1 if not found.

bsearch(source,pattern, start)

Backward search.

copy(source, from, count)

Copy count characters from source beginning at from.

replall(source, pattern, new)

Replace all occurrences of pattern in source by new.

lower(source)

Convert to lower case.

upper(source)

Convert to upper case.

mstr(string)

Enclose string in „" and mask special characters.

Lists

tokcnt(source[,sep])

Count tokens in source-list separated by sep.

tokcat(source1, source2 [,separator])

Concatenate two lists.

tokunion(source1, source2[, separator])

Union two lists.

tokisect(source1, source2  [, separator])

Return the intersection of two lists.

tokdiff(source1, source2  [,separator])

Return a list holding all elements of source1 except of those of source2.

Color

rgbval(colorname)

Return 24bit RGB value of color name.

rgbval(r, g, b)

Compute RGB value of specified (numerical) color-components.

Statements

set(var, expr)

Store expr in variable var. var is implicitely defined.

cond(cond1, expr1, ..., expr_else)

Evaluate cond1, if true return expr1, if false evaluate next condition or return expr_else, resp.

while(cond, loopexpr[, resultexpr])

While cond is true evaluate loopexpr. Returns resultexpr.

fortok(varname, source, sep, loopexpr [, resultexpr])

For each element in the list source evaluate loopexpr. The current element is stored in varname. The list is separated by sep. The statement returns resultexpr.

Error-Handling

try(expr, failexpr)

Returns expr if it can be evaluated successfully, else returns failexpr.

Type-Checking

type(expr)

Returns the type of the given expression:

"string", "integer", "real", "measure", "time", "expression„ or "undefined„.


 

The Core Expressions functions:

#Call the value of the instance attribute

aval (instID , attrName)
aval ( attrName )
aval ( 
instName , attrName )
aval ( 
className , instName , attrName )

#Returns a formatted string of the value. For INTERREF attributes, format is returned with the following replacements: %o by object name, %c by class name, %m by model name, %t by model type name of the target model.
avalf ( format , instID , attrName )
avalf ( format , attrName )
avalf ( format , instName , attrName )
avalf ( format , className , instName , attrName )

#Returns the value of the same-model attribute specified by attrName.
maval ( attrName )

#Returns the models referenced from the specified instance INTERREF attribute attrName.
irtmodels ( attrName )
irtmodels ( instID , attrName )
irtmodels ( instName , attrName )
irtobjs ( attrName )
irtobjs ( instID , attrName )
irtobjs ( instName , attrName )

#Returns the objects  referencing this instance/model. The usage of this function is not recommended due to high performance costs.
objirsobjs ()
objirsobjs ( targetName )
objirsobjs ( targetID )
modelirsobjs ()

#Returns the ID of the referenced attribute profile from the specified same-instance PROFILEREF attribute.
profile ( attrName )

#Returns the value of the instance attribute of a referenced attribute profile.
paval ( profilerefAttrName , attrNameInProfile )

#Returns a formatted string of the value of the instance attribute of a of a referenced attribute profile.
pavalf ( format , profilerefAttrName , attrNameInProfile )

#Returns the to/from-object.
ctobj()
cfobj()
ctobjs ( relnName )
ctobjs ( instid , relnName )
cfobjs ( relnName )
cfobjs ( instid , relnName )

#Returns the connectors of the specified type relnName between the specifed objects. An objs parameter can be a single ID or a string containing a sequence of IDs.
conn ( relnName , fromObjs , toObjs )

#Returns the modelling object owning the RECORD attribute containing the row rowID
objofrow ( rowID )

#Returns the number of rows of a record
rcount ( recordAttrName )

#Returns the ID of the internal object representing the record row with the given rowIndex (between 1 and rcount()).
row ( recordAttrName , rowIndex )

#Returns the sum of all values of the record column columnName. You can sum INTEGER, DOUBLE, TIME, and EXPRESSION attributes.
rasum ( recordAttrName , columnName )
rasum ( idStr , recordAttrName , columnName )

#Returns the sum of all values of a column of a record in an attribute profile. You can sum INTEGER, DOUBLE, TIME, and EXPRESSION attributes
prasum ( profileAttrName , recordAttrName , columnName )

#Returns '1' if the model modelID is loaded, otherwise '0'.
isloaded ( modelid )

#Returns all objects of the class className in the specified model modelID.
allobjs ( modelID , className )

#Returns a string with the IDs of the AQL expression's result
aql ( aqlExpr )

#Returns the ID of the previous swimlane.
prevsl()

#Returns the ID of the next swimlane.
nextsl()

#Returns the sum for all objects specified by idStr of all attribute values of the attribute specified by attrName.
asum ( idStr , attrName )

#Returns the maximum for all objects specified by idStr of all attribute values of the attribute specified by attrName.
amax ( idStr , attrName )

#Returns the weighted sum for all objects specified by instIDStr of all attribute values of the attribute specified by objAttrName weighted with attribute values of connectors specified by connIDStr and connAttrName.
awsum ( instIDStr , objAttrName , connIDStr , connAttrName )

#Returns the class ID.
class ( instID )
class ( className )

#Returns the model type name.
mtype ()
mtype ( modelID )


#Returns the classes allowed in the model type modelTypeName.
mtclasses ( modelTypeName )

#Returns the visible relation classes in the model type modelTypeName.
mtrelns ( modelTypeName )

#Returns all class/instance/relation attributes of the class classID/ relationID.
allcattrs ( classID )
alliattrs ( classID )
allrattrs ( relationID )


#Returns the name of the attribute attrID.
attrname ( attrID )

Returns the type of the attribute attrID
atttype ( attrID )

Additionally, the following variables are preset for every EXPRESSSION attribute:

  • objid with the ID of the own object/connector
  • classid with the ID of the own class/relation class
  • modelid with the ID of the model containing the own object
  • attrid with he ID of this attribute

 

AdoScript Expressions:

The command EVAL_EXPRESSION introduces a Core Expression (see above) without the need for an EXPRESSION attribute and its structure is documented below. objid must be quoted, if the expression is object-related and the model id needs a model related expression. The type of the result is the same as the result of the expression. 

EVAL_EXPRESSION coreExpr [ objid: id | modelid: id ] .
# --> RESULT ecode: intValue result: value
# value : double | integer | string | time .

 

 

Hands On

Community

There are no results.

Development Tools/Development Environment