Skip to content

Miscellaneous Functions (MiscUtils.xml)

James Dunkerley edited this page Feb 21, 2019 · 7 revisions

This provides a few additional general methods for data preparation.

Each function listed below states the category it is added to.

Unit tests for all these functions in MiscUtils.Test folder.

Version

Added to Specialized category

Syntax: VERSION()

Examples:

  • Version() returns 11.0 (assuming running in 11.0!)
  • Version(3, ) returns the Build and Revision number

Gets the Major and Minor version numbers of the Engine as a number. Other parts of the version can be specified by passing arguments to the function.

IfNull

Added to Specialized category

Syntax: IFNULL(Value, ValueIfNull)

Examples:

  • IFNULL('A', 'B') returns A
  • IFNULL(NULL, 'B') returns B

If the first parameter is NULL, returns the second parameter.

  • If both Value and ValueIfNull are NULL, returns NULL.

Coalesce

Added to Specialized category

C++ Function - Coalesce

Syntax: COALESCE(Value1, Value2, ...) Takes variable number of parameters.

Examples:

  • COALESCE('A', 'B') returns A
  • COALESCE(NULL, 'B') returns B
  • COALESCE(NULL, NULL< 'C') returns C

Generalised version of IfNull, returns the first parameter which is not NULL.

  • All parameters must be same general type (numeric vs text (including dates/datetimes as text)).
  • Minimum of 2 parameters, but can be as many as you need.
  • If all parameters are null, returns NULL.

ReportError

Added to Specialized category

Syntax: ReportError(Condition, Message, ReturnValue) Defaults: Condition = True, Message = "Reporting An Error!", ReturnValue = NULL

Examples:

  • ReportError() returns an error of Reporting An Error!
  • ReportError(0) returns NULL
  • ReportError(1, 'An Error') returns an error of An Error
  • ReportError(0, 'An Error', 3) returns 3
  • ReportError(0, 'An Error', 'All Ok!') returns All Ok!

Allows you report an error from a function or pass through a value.