How can I change the number of digits (0 padding) of a numerical value on DA?

Follow

You can use the Expression area of a step such as "Assign" within a Device Automation step (Desktop Automation step since ver.10.4).

Please refer to the procedure below.

※It explains how to change a single-digit value to a 3-digits one.

 

Procedure

1.Create a numerical variable that contains an arbitrary number. (variable name: int)

   1.png

 

2.Create a text variable. (variable name: text)

   2.png

3.Add an Assign step, and set the text variable of step 2 in "Variables".

 

4.Enter "”00”+text(int)" in "Expression". (activate "=")

   3.png

<Supplement>

If the number of digits of a numerical value stored in an integer variable changes at each process, you can use conditional branching with the formula entered in "Expression", such as in step 4.

<Example>Expression to change the number of added 0 depending on the number of  digits

length(text(int))==1?"00"+text(int):length(text(int))==2?"0"+text(int):text(int)

31733-4.png

 

※ length()・・・You can count the number of characters.

    If the number of characters of a variable is 1 digit: "00" + variable; if 2 digits: "0" + variable; if 3 digits: no 0 padding.

 

Reference

Method to add prefix characters and change the number of digits of a numerical value on DS

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.