Calculations in M-Designer
Sommaire
How to make calculations in M-Designer
1 - Create "Integer Memory" or "Float Memory" zones that get numeric information from XML or spool file
Field names : ZONE1 and ZONE2
2 - Create a "Math. Calculation Memory" zone and type calculation in "Text printed after" field
Field name : CALCFIELD
Text printed after : [[FIELD1]] + [[FIELD2]]
3 - Display result in a new "Memory Replacement" zone
Text printed after : [[CALCFIELD]]
Thousands and decimal separators
M-Designer Preferences
Two options in the Calculation tab let you specify the thousands separator and decimal separator. They are used for retrieving integer or real values in the application (through the use of Memory zones), the calculations made and the results displayed in the preview. They have no effect on how projects are generated on the server.
M-PS parameters (mapping.conf)
Two equivalent variables exist for the execution on the M-Processing Server side: MAPCPYSPLF_THOUSAND and MAPCPYSPLF_DECIMAL.
These settings are used globally for the server. However, they can be set differently before running any Mapping command in order to apply other separators used in other countries.
Comparison between M-Designer Preview and server-side calculation results
The following differences are fixed in M-Designer 8.0.5 or higher.
The M-Designer preview does not interpret the type of fields, only the values (decimal separator or not).
Server-side calculation (with mapcpysplf) interprets only the type of fields, regardless of the values.
For the following examples, the thousands separator is " . " and the decimal separator is " , " (French standard)
Calculation | Field Type | M-Designer Preview | M-PS Composition | Comments |
---|---|---|---|---|
[[val1]] + [[val2]] 645 + 110 |
Integer | 755 | 755 | "Float type" is interpreted only for XPS generation |
Float | 755 | 755,00 | ||
[[val1]] / [[val2]] 645 / 110 |
Integer | 5 | 5 | |
Float | 5 | 5,86 | ||
[[val1]] + [[val2]] 645,13 + 110,45 |
Integer | 755,58 | 755 | If values contain a decimal separator then M-Designer assumes fields as float, but this has no impact on server side composition. |
Float | 755,58 | 755,58 | ||
[[val1]] + [[val2]] 645.13 + 110.45 |
Integer | 75.558 | 75.558 | Because of M-Designer preferences and mapping.conf, "." is not interpreted, so it is assumed as 64513 + 11045 |
Float | 75.558 | 75.558,00 | ||
,[[val1]] + [[val2]] 645 + 110 |
Integer | 755,00 | 755 | If calculation contains a decimal separator then M-Designer assumes fields as a float. This prefix has no impact on XPS generation. |
Float | 755,00 | 755,00 | ||
,[[val1]] / [[val2]] 645 / 110 |
Integer | 5,86 | 5 | |
Float | 5,86 | 5,86 |