<add-leading-zeros>
Purpose/Function
Generate a string representing a numerical value with a given number of zeros prepended to it. Assumes that the number to be converted is a reference (otherwise, the leading-zero string could be constructed directly inside the script ...).
For instance:
- with places = 4
- 4.2483 >>> "0004.2483"
- 361 >>> "0361"
- -0.3423 >>> "-0000.3423"
- 53764 >>> "53764"
- with places = 1
- 0.753 >>> "0.753"
- .853 >>> "0.853"
- -.2 >>> "-0.2"
- with places = 0
- 0.753 >>> ".753"
- .853 >>> ".853"
Attributes
NAME |
TYPE |
DEFAULT VALUE |
DESCRIPTION |
---|---|---|---|
number |
|
(required) |
the number to be transformed; can be a Primitive wrapper or a string representing a number |
places |
|
0 |
the number of places to the left of the decimal to occupy by zeros, if not by some other digit |
Elements
None.
ReturnValues
DEFAULT NAME |
TYPE |
DESCRIPTION |
---|---|---|
zerosAdded |
|
the resulting number string with zeros prepended |
Examples
<ogrescript> <declare name="n" double="-3.4082"/> <add-leading-zeros number="${n}" places="10"> <return-value defaultName="zerosAdded" assignedName="n"/> </add-leading-zeros> </ogrescript>