What is an Expression?

In This Lesson, You Will Learn:

  • The definition of an expression.
  • The three types of component that can make up an expression: identifier, operator and literal.
  • How to assemble a basic expression.
  • Valid naming conventions for identifiers in the KnowledgeKube Expression Engine.

In programming, an expression is a piece of code used to perform a task and return a value. Expressions are built using a combination of Identifiers, Operators and Literals. You can use an expression to calculate values, validate data, and set a default value for a field or control.

The four element types that can be used to build an expression, with examples.

The following example expression contains all of these elements:

Sum( PurchasePrice ) * 0.08

Sum() and PurchasePrice are both examples of identifiers, the asterisk symbol (*) is an arithmetic operator, and "0.08" is a literal.

An expression can be as complex or as simple as its purpose dictates. The following expression is less complex than the previous example, containing a single operator and a single literal:

>0

The above example returns True when it is compared to a number that is greater than 0, and False when it is compared to a number that is less than or equal to 0.

 

<< Previous: Expression Cookbook | Next: Identifiers >>