Expressions and Functions

Expressions and functions are important software concepts. As a power-user, you need to understand the them.

  • Expression and functions are everywhere in software (including Umana) and mathematics. If you've used Excel, you've used them already.

Expressions

An expression like something from algebra: a shorthand string of letters, numbers, operators (, , , etc), and functions, which expresses how to calculate something. It is a rule or recipe.

In Excel, an expression is what you would put in a cell after the = sign, to define the calculation.

  • In algebra, you used expressions to calculate numbers. In software, we also use expressions to get other things like text (strings of characters), dates, and values TRUE and FALSE.

Examples

  • 12
  • UNITRATE * 1.5
  • pers.E_LASTHIRE + 30
  • BOSS(pers.E_PERSID)
  • pers.E_LASTNAME + ", " + pers.E_FIRSTNAME

Creating an expression

The Umana Expression builder - Tools can often guide you to create an expression.

An expression is made up of basic expressions like:

  • Constants: like numbers (10, 13.4) or text ("the employee"), or a date {^2001/07/16}
  • Variables (X, Y, Today, l) and data-base fields (pers.E_PERSID) These are like the ingredients in a recipe.

And any combination of other expressions, put together with

  • Operators: , , OR, AND, and parentheses
  • Function calls (using expressions as arguments).

Variable names and data base fields are NOT case sensitive in Umana. You can write T_HOURS or t_hours; they are the same thing. Similarly for function names.

Using expressions

Umana stores your expressions in the data base to tell it how to calculate stuff. For example

  • The rule to calculate an employee's vacation entitlement. It may depend on the employee's seniority.
  • A field to print on a report
  • The calculation of an insurance premium. It may depend on the employee's age and salary.

An expression is just a rule. To get the result, it needs to be evaluated – in the same way you can't eat a recipe; you have to evaluate (cook it) using your ingredients.

Since ingredients for an expression are fields in the data-base, the result will vary depending on what record is being used. Thus, the expression timedt.T_HOURS will give a evaluate to a different value for different records in the data.

Functions

Function are everywhere inside Umana – and every other software too.

A function is like a tiny circuit inside Umana that does a very specific job, in isolation.

A function is also called a black box, because you know what goes in and what comes out, but not necessarily what's inside.

You give the function some "arguments" (input) and it gives you back a result (output).

How to use a function

You use (invoke) a function by putting it in expression. Here is the syntax:

  • Put the function name first, followed by an open-parenthesis, followed by the argument(s) in order separated by commas, and finally a close-parenthesis.

  • For example, in
    ROUND (T_UNITRATE * 1.5 ,  2)

    • The function name is ROUND
    • The first argument is T_UNITRATE * 1.5
    • The second argument is 2
    • Note the opening and closing parentheses
  • The function knows which argument is which, by the order in which they are passed.

Remember, an expression is made of up of simple expressions, put together with operators and functions, making more complex expressions. So a function invocation, is itself an expression.

Examples

There are hundreds of functions in Umana. Some are part of the language, some are part of the Umana product, and there may be some which were developed (custom) just for you. They are all invoked in the same way.

  • In object-oriented languages, sometimes functions are packaged together into objects. They are invoked with the name of the object name followed by the function name. It's a handy way to group common stuff together.

© Carver Technologies, 2024 • Updated: 06/21/21
Comment or report a problem with this topic