Pass number/string with leading 0's as paramater

I have a value 002 that I am trying to pass as a parameter (I’ll call it pNum) from page A to page B for use in an indirect tag path. I have tried a couple different things on page B but nothing has worked yet. If, on B I set my custom property pNum as a String the value comes through as 2. If I set the custom property to be an integer, same thing: 2. If I add quotes to it, the String keeps the quotes and gives me “002”, and the Integer errors out - as expected.

The value will be used in an indirect tag path (Alarms/p{1}/Alarm) resulting in something that looks like Alarms/p002/Alarm where {1} is the custom property pNum.

Am I missing something obvious?

Is there a way to remove quotes with an expression? I could use two custom properties, one would receive the value as “002” and the other would read that value, strip off the quotes (002) and be used in my tag path.

Any suggestions would be appreciated.

Hello, Stuart.

Have you tried using zfill(width)?

Pad a numeric string s on the left with zero digits until the given width is reached.


pNum = '2'
print pNum.zfill(3) -> '002'

Since the tag path is a string, you can easily concatenate the formatted pNum value.

I hope this helps.


Are you using python scripts or expressions?

I’d guess it’s easiest to define a custom property on whatever UI element you want to use, and then make an expression for that property to get the string to use in the tagpath. For an expression, the best way is probably to use “numberformat” like this:

"p" + numberFormat(5, "000")

This will return the string “p005”.


Hi all,

Sorry to revive this dead post but I am having the same issue and am wondering if anyone has a solution. I am trying to pass a string parameter with values of 01, 02, 03 etc. The leading zero is always dropped once passed. As a result my indirect tagging fails because my tag names are EX01, EX02, SC22 etc.

Never mind! I spoke too soon and have figured it out.

Thank you to Sandnerd17 for the clue.

I created an expression binding on my custom property (that was holding the passed in value). I used numberFormat({Root Container.parameterName},“00”) as the expression and the leading zero was added back.