UnitValue

Returns the numerical value of a measurement with its associated unitspan, after an optional unit conversion. A unitspan is a string consisting of a number followed by a valid unit of measurement.

Syntax

UnitValue(s1 [, s2 ])

Parameters

Parameters

Description

s1

A valid string containing a numeric value and a valid unit of measurement (unitspan). Recognized units of measurement are:

  • in, inches

  • mm, millimeters

  • cm, centimeters

  • pt, picas, points

  • mp, millipoints

s2 (optional)

A string containing a valid unit of measurement. The function converts the unitspan specified in s1 to this new unit of measurement.

If you do not include a value for s2, the function uses the unit of measurement specified in s1. If s2 is invalid, the function converts s1 into inches.

Examples

The following expressions are examples that use the UnitValue function:

Expression

Returns

UnitValue("2in")

2

UnitValue("2in", "cm")

5.08

UnitValue("6", "pt")

432

UnitValue("A", "cm")

0

UnitValue(Size[2], "mp")

Returns the measurement value of the third occurrence of Size converted into millipoints.

UnitValue("5.08cm", "kilograms")

2

// Ethnio survey code removed