Loading...
 

CX_VALUE - Value

CX_VALUE

Class hierarchy
Description:

This class allows real numbers to be specified with a unit . Since each object of this class knows its unit , it is guaranteed for a value that only permitted arithmetic operations are possible: e.g. "1 m + 5 h" is an impermissible addition, while "1 m + 30 cm" results in the value "1.3 m". Furthermore, a value can also become unitless : this state can arise in arithmetic operations, such as "5 m / 3 cm", and is represented by a value without a unit: e.g. "1.2356".

Since different units are used in different countries and these can be held in the system at the same time, the results must potentially be converted into the desired target unit after the calculation. In the USA, for example, the unit "gallon" is used instead of "litre". To obtain the desired unit after a calculation operation, the functions Convert or ConvertWeak are available.

Code example:

Var(value1, value2)
CreateTransObject(CX_VALUE) -> value1      // CX_VALUE erzeugen
"50cm" value1 Put                          // und Wert zuweisen
.................
55.4m -> value2                        // oder so 
................
value1 value2 +=     // Ergebnis :    value1 = 5590cm

Special case temperatures
Temperatures are usually specified in °C, °F or Kelvin. These specifications are also supported by the ClassiX system. However, since °C and °F are not simple factors (10°C + 10°C ≠ 2 - 10°C ≠ 20°C), when a CX_VALUE with °C or °F(224347) is applied, the value is implicitly converted to kelvin. Using CX_VALUE։։Convert, a temperature can nevertheless be explicitly converted to °C or °F, but these values cannot subsequently be offset against other units.

Default values

CreateTransObject(CX_VALUE) creates an object
- with the unit of measurement registered in the ClassiX system, see SetDefaultUnit and
- with as many decimal places as specified for this unit.
If SetDefaultUnit has not yet been called, the default unit is "piece". This unit has 0 decimal places by default.

Display on screen

The following options exist for displaying objects of this class:

1. use of a surface object of type String. In this case the object is specified in a single input field. The flag NF_DIMENSIONED must be used so that the unit is also displayed during export. If no flags are passed, the flags NF_DIMENSIONED and NF_AUTOMATIC_DECIMALS are used by default. The following figure shows an example (program code):

2. the use of two surface objects of the type String, in one of which the numerical part and in the other the unit is entered. The Numeric interface object can also be used to manage the numerical portion. It is possible to use the Enumeration or Combo fields for the unit, so that the user can be provided with a selection of units(programme code):

Note: In ClassiX® the components of a compound unit are displayed separated from each other by the multiplication sign "*" and the separator for fractional numbers (e.g. "/") set in the system. It is important to note that no brackets are used to avoid complicating the output of a unit. Thus the unit "m/s*kg" corresponds to the unit "m/(s*kg)" and not to the unit "m*kg/s".

In connection with these display options and certain InstantView®instructions, the flags belonging to the object play an important role, as they can be used to modify the display of the object.

Behaviour with Put
For the import, the same rulesapply regarding the precision for CX_VALUE as for CX_NUMERIC.

ParameterType Example Conduct
CX_VALUE 3€ Numerical value is transferred to the target object with unit. The unit ? is treated as a regular unit.
CX_NUMERIC 1.25 Numerical value is accepted and the unit remains unchanged.
INTEGER 7
STRING ""
"7"
A string without a unit is interpreted as a number and treated as if the number had been passed on the stack. An empty string is interpreted as the number 0. The unit does not change here either.
STRING "€"
"?"
A string consisting of only one unit is interpreted as CX_VALUE with the numeric value 0. The numeric value is therefore set to 0 and the unit is taken from the string. ? is also treated as a regular unit here.
STRING "7€" A string consisting of unit and number is also interpreted as CX_VALUE and imported as if there was a CX_VALUE on the stack instead.

Operators
Operator Brief description
+, -, *, / Arithmetic
+=, -=, *=, /= Arithmetic
>, <, = Compare
List of methods (MDI)
Function MA* Parameters Return Brief description
abs OBJECT Unsigned value
arc OBJECT radian measure
arccos OBJECT Arcus Cosine
arcsin OBJECT Arc Sine
arctan OBJECT Arcus tangent
AutoFormat INTEGER, INTEGER OBJECT Returns a CX_VALUE object formatted according to the given number of digits before and after the decimal point.
ceil OBJECT Smallest integer greater than object
ChangeUnitName (MLSTRING) Rename unit
Convert (STRING) OBJECT Converting to another unit
ConvertWeak (STRING) OBJECT like Convert, on error NULL back
CopyUnitName (INTEGER) Change unit name
cos OBJECT Cosine
cosh OBJECT Cosine hyperbolicus
cot OBJECT Cotangent
DigitalHours Input/output control of time units
EqualUnit (OBJECT) INTEGER Checks whether two values have the same unit
exp OBJECT Exponent
floor OBJECT Largest integer smaller than object
Get1Value OBJECT Return: Number with value 1
GetUnitParameter OBJECT Return: Unit
GetValue OBJECT Returned: Object as value
GetValuePer OBJECT Returned: Object as value break
ValuePer (CX_VALUE) OBJECT Returned: Object as value break
GrossAmount (OBJECT) OBJECT Add up percentage value
HasUnit (STRING) INTEGER Checks whether the value has a specific unit
ImportObject (OBJECT) INTEGER Setting the number
IsArea INTEGER Test unit area: Areas
IsCompound INTEGER Test unit range: composite units
IsCurrency INTEGER Test unit range: Currencies
IsDuration INTEGER Test unit range: Times
IsEuroCurrency INTEGER Test unit area: Euro currencies
IsGeometrical INTEGER Test unit range: lengths, areas or room specifications
IsLength INTEGER Test unit range: Lengths
IsPacking INTEGER Test unit range: Packaging
IsPieces INTEGER Test unit range: Unit specifications
IsTemperatures INTEGER Test unit range: Temperatures
IsUserDefined INTEGER Test unit range: self-defined units
IsVolume INTEGER Test unit range: Room specifications
IsWeight INTEGER Test unit range: Weights
ln OBJECT natural logarithm
log OBJECT Logarithm. Base 10 (log10 x)
max (OBJECT) OBJECT Comparison "Larger" if (a > b) a else b
min (OBJECT) OBJECT Comparison "Smaller" if (a < b) a else b
NetAmount (OBJECT) OBJECT Division with percentage value
pow (OBJECT) OBJECT Calculates number high Parameter number xy
RateOfLastConversion OBJECT Return: last conversion rate, which was executed with UnitConvert or UnitCrossConvert from unit conversion table.
ResetUnitName Undo changes to ChangeUnitName and CopyUnitName.
round (OBJECT) OBJECT like Round, but with return of the object
RoundAutomatically OBJECT Round the number with the precision that results from the unit
RoundByPrecision Rounding with current precision
SetDefaultCurrency Set default currency unit
SetDefaultUnit Change the preset unit
SetValue STRING, INTEGER Import string as value
are OBJECT Sine
sinh OBJECT Sinus hyperbolicus
sqrt OBJECT Square Root
tan OBJECT Tangent
tanh OBJECT Tangent hyperbolicus
truncate (OBJECT) OBJECT like Truncate, but with return of the object
Unit * Input/output control of the unit as text
UnitEnum * Input/output control of the unit as internal value
UnitNumber INTEGER Internal value of the simple unit
ValuePer CX_VALUE CX_VALUE_PER Creates a value break (CX_VALUE_PER)
Add CX_AMOUNT CX_AMOUNT Operator + as function
AddAssign CX_AMOUNT Operator += as function
AdjustPrecision Adjusting the accuracy
Amount OBJECT Return of the object value
AmountWeak CX_AMOUNT
ChangeSign Reverse sign
DiscreteRange (OBJECT, OBJECT, OBJECT) INTEGER Test the dental area
DivAssign CX_AMOUNT Operator /= as function
Divide CX_AMOUNT CX_AMOUNT Operator / as function
GetFraction OBJECT Number in fractional form
GetNumeric OBJECT Return: Object as a real number
InWords (INTEGER, INTEGER) MLSTRING Convert number into number words
IsNegatives INTEGER Test negative sign
IsZero INTEGER Test number to zero
MulAssign CX_AMOUNT Operator *= as function
Multiply CX_AMOUNT CX_AMOUNT Operator * as function
PercentDifference (OBJECT) OBJECT Difference of two numbers as a percentage value
Precision * Changing the accuracy
PrecisionAdjusted OBJECT like AdjustPrecision, but with return of the object
Reciprocal OBJECT Calculation of reciprocal values
Round (INTEGER) Rounding the number
Rounded (INTEGER)
SetNumeric STRING, INTEGER Import string as number
SetPrecision (INTEGER) Set number of decimal places
SetZero Set number to zero
string INTEGER CX_STRING Returns the string representation of the object
SubAssign CX_AMOUNT Operator -= as function
Subtract CX_AMOUNT CX_AMOUNT Operator - as a function
Truncate (INTEGER) Truncation of decimal places

In addition, two standard numbers of decimal places are predefined for each unit. These can be queried via the following (static) functions:

Function name Brief description
UnitPrecision national accuracy of the unit
RateTablePrecision international accuracy of the unit
Data directory (DDI)
Data field Type Reference class I* Brief description
this CX_NUMERIC The number

* I = Indexable data field

Use in AppsWH
Module Brief description
calcula.mod Unit pocket calculator module
qm\tmprture_qm.mod Conversions between temperatures Editing module