expressions - Gnorion/BizVR GitHub Wiki

Expressions Involving Functions

What are Functions

A function is a predefined operation that takes zero or more inputs and produces one or more outputs.

For example y = f(x)

Here are some ways you can use functions in decision table cells:

image

When used in a condition it's only the return value that you care about. When its used in an action it must be part of an assignment in one of the two formats shown

Conceptually its the same idea as a decision table (and also a Decision) but you don't have to define how they work.

BizVR comes with a comprehensive set of functions that can be used anywhere inside a decision table - in conditions and in actions.

Although BizVR does not have every possible function that could exist it does have a mechanism for you to import external javascript libraries whose functions you can then use in your decision tables.

There may be libraries that you write or find on the internet Including externally defined function libraries

Types of Function

There are three formats that you can use:

INFIX

  • x+=y Adds y to x (or concatenates them if they are strings)
  • x < y Compares x and y returns true if x is smaller than y

image

METHODS - These are convenient if you want to build sequences of operations

The operations are applied from left to right

  • customerName.contains('SMITH') returns true if the variable customerName has 'SMITH' anywhere within it
  • customerName.toUpper.contains('SMITH') returns true if the uppercase for of customername contains 'SMITH'

image

TRUE FUNCTIONS

You can also use the operations in the formal function syntax but this form can be harder to follow if you are nesting function calls. The operations are applied from inside outward,

  • contains(customerName,'SMITH') returns true if the variable customerName has 'SMITH' anywhere within it
  • contains(toUpper(customerName),'SMITH') returns true if the uppercase form of customerName contains 'SMITH'

image

Nesting function calls can be harder to understand so its clearer if you express it in two steps

  • customerNameUP=toUpper(customerName)
  • contains(customerNameUP,'SMITH')

Different Functions are available Depending on the Data Type

⚠️ **GitHub.com Fallback** ⚠️