Data Sheet
dScript
dScript User Manual v2.15
Padding numeric output
Sometimes when displaying numeric output, you will want to use a constant width, regardless
of the number. To achieve this just add a number following the format control character.
{D3} will display the number as three digits.
4
34
234
6234
That worked well except for the last number. If a number is larger than the number of places
allocated it will use as many as needed to display the result. Make sure you plan for the largest
expected number. Using {D4} here will work.
4
34
234
6234
Numbers can also be preceded with 0 instead of a space. Put a 0 between the control character
and the pad count, like this {D04}
0004
0034
0234
6234
X = 42
S1 = “Variable X contains ” + {B08} X
results in “Variable X contains 00101010“
S1 = “Variable X contains ” + {B04} X
results in “Variable X contains 101010“
S1 = “Variable X contains ” + {D04} X
results in “Variable X contains 0042“
S1 = “Variable X contains ” + {H04} X
results in “Variable X contains 002A“
Copyright © 2016, Devantech Ltd.
All rights reserved.
www.robot-electronics.co.uk
22