﻿ Additional Features > The Code Definition Window > Calculated Codes

# Calculated Codes

The value of a code can either be input from the user or calculated. If a code is to be calculated, the calculation rule must be defined in the Calculate field in the Code Definition window.

When defining a calculation rule, you can use any numerical database field for a weight item. Please note that database field names must be written in brackets, e.g. the database field Weight must be written [Weight]. The following database fields can be included:

 [Weight] [VCG_min] [NoOff] [VCG] [VCG_max] [Factor] [LCG] [LCG_min] [Length] [TCG] [LCG_max] [Width] [C01] to [C99] [TCG_min] [UnitWeight] [TCG_max]

The database fields [NoOff], [Factor], [Length], [Width] and [UnitWeight] correspond to Quantity 1 to Quantity 5. These are defined in the Options window. When including one of these quantities in a calculation formula, please refer to its default title:

Quantity 1        =        [NoOff]

Quantity 2        =        [Factor]

Quantity 3        =        [Length]

Quantity 4        =        [Width]

Quantity 5        =        [UnitWeight]

Codes [C01] to [C99] can only be used in the calculation formula if the values are numerical.

Usually a code with field type ComboBox or ListBox has predefined code-values. Each code value can hold information of VCG_min, VCG_max, LCG_min, LCG_max, TCG_min, TCG_max, Factor and UnitWeight. These fields can be included in a calculated code formula using the following syntax:

[Code].[Field]                Example:        [C03].[Factor]

The calculation rule accepts the operators + (add), - (subtract), * (multiply) and / (divide).

The ABS() function is available for calculating the absolute value of a database field. Examples of usage:

ABS([TCG])

ABS([WEIGHT]*[TCG])

An example of a commonly used calculated code is the Vertical Moment:

Vmom = Weight * VCG        à        [Weight]*[VCG]

Please refer to Chapter Tutorial: Add Custom Codes and Tutorial: Define Calculated Codes for more detailed examples.