Inhaltsverzeichnis

User-defined functions

In REX/PSI Next Generation, you have the option of creating user-defined functions to customise specific calculations and simulations to your requirements. These functions make it possible to formulate complex mathematical expressions and conditions in order to calculate or adjust specific parameters in the simulation. To create these functions, we have developed our own minimal programming language that supports mathematical and logical expressions. This section explains the functionality, syntax and application of the user-defined functions in detail.

Overview: Manage user-defined functions

The Manage user-defined functions dialogue provides a central interface for creating and managing user-defined functions. This dialogue is divided into several sections:

Check and evaluate the function

Once you have defined your function, you can click on ‘OK’ to check whether the function has been formulated correctly. The software performs a syntactic check and if there are any errors, these are highlighted in colour in the text field. This helps you to quickly identify and correct sources of error.

Mathematical expressions

User-defined functions usually consist of mathematical expressions that represent a value. You can use variables, operators and mathematical functions in these expressions. The most important elements that can be used in a mathematical expression include

Calculation rules for mathematical expressions

Logical expressions

Logical expressions represent a truth value and can be formulated using comparison operators and logical operators:

Logical expressions are often used for conditional statements to make the execution of commands dependent on a certain condition.

Anweisungen

In user-defined functions, there are different types of statements that start on a new line and control the result of a mathematical or logical expression:

  <variable> = <mathematical expression>
  return <mathematical expression>

How to deal with invalid values

If an operation is not defined (e.g. division by zero), the special value invalid is returned. This invalid value can also be used as the result of a function, in which case no value is displayed for this interpolation point.