Esko Logo Back to Esko Support
Choose your language for a machine translation:

 

Description

When the result of a Script SmartName is a number, you want to convert the result to another unit and/ or round the result to a certain number of decimals.

Procedure

Example: A Script SmartName to calculate the sum of two SmartNames representing the left and right margin from an XML file, in millimeters.

Script
[Left Margin] + [Right Margin]

The following procedure describes how to convert the result of this Script SmartName to another unit and/ or round the result to a certain number of decimals.

For Automation Engine 12:

To convert the result of the sum of the two SmartNames to another unit (in this case inches), multiply the result of the sum with the factor needed to convert it to the other unit, using JavaScript.

To round the result to a certain number of decimals, use the JavaScript toFixed() method (for more information, see http://www.w3schools.com/jsref/jsref_tofixed.asp).

The script for the Script SmartName becomes the following:

Script
(([Left Margin] + [Right Margin])*.0393700).toFixed(3)

For Automation Engine 14 or newer:

To convert the result of the Script SmartName (or any other type of SmartName) to another unit and/ or round the result to a certain number of decimals, use the SmartName Formatting Options.

Article information
Applies to

Automation Engine 12.0

Created10-Apr-14
Last revised08-May-14
AuthorJAHI, MABM
CW Number 
Contents