# Variables losing leading zeros

**URL:** https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195
**Category:** Discussion
**Created:** [September 8, 2006, 11:13am UTC](https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195 "2006-09-08T11:13:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 8, 2006, 11:13am UTC](https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195/1 "2006-09-08T11:13:54Z")

</div>

I’m trying to automate our current build process, which uses threedigit build numbers, such as 013. There are a number of places where weput the build number in a filename, and we want it to have all threedigits so they will sort nicely when we get past build 100. I’vecreated a %BNUM% variable, but when I try and us it in a filename or ina Text Replace, the leading zero is getting dropped, so "cd…/install/%BNUM%’ gets replaced as “cd …/install/13” instead of “cd…/install/013”.   
  
It looks like FinalBuilder is assuming that 013 is the same as 13, since they are the same numerically.  
Is there any way to force FinalBuilder to treat a variable as a textstring instead of interpreting it as a number? Or is there a way totell it to always make a 3 digit number, even if it means puttingleading zeros? Something like the printf format string “%03d” would benice. Or is there some other way to do what I want?  
  
Thanks,  
 Keith Hearn  
 Build/Release Engineer  
 Devicescape Software

---

<div class="post-metadata">

### Author: ![tate](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/t/e19b73/32.png) [@tate](https://www.finalbuilder.com/forums/u/tate)
#### Post date: [September 8, 2006, 11:27am UTC](https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195/2 "2006-09-08T11:27:28Z")

</div>

Hi Keith,  
  
How are you setting the build number? If you use the Set Variable action, there is an option to force it to be a string value, which means it shouldn’t be interpreted as numerical (and therefore not drop the leading zero).  
  
You also might want to have a look at PropertySets. They are designed for handling version numbers, including things like padding the values when outputing their values.  
  
.t8

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [September 9, 2006, 2:06am UTC](https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195/3 "2006-09-09T02:06:42Z")

</div>

Ahh, I was just setting it via the “Edit Variables” button, whichdoesn’t offer the chopice of types. When I set it at runtime with the"Set Variable" action, it does exactly what I need.   
  
Thanks!  
  
 Keith

---

<div class="post-metadata">

### Author: ![deleted\_user](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/deleted_user/32/937_2.png) [@deleted\_user](https://www.finalbuilder.com/forums/u/deleted_user)
#### Post date: [February 24, 2009, 3:44am UTC](https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195/4 "2009-02-24T03:44:45Z")

</div>

I'll bring back this one back from the dead.

I have the same situation but it doesn't work unless I go "around" it. I have a macro variable that needs to be set as string.  
  
I currently do the following :   
  
1) Edit variable - value=01, Macro unchecked  
2) Set variable : variable to string  
3) Edit variable - Macro checked.  
  
I need to do this because macro variable are not choosable in the "Set Variable", but when doing it in this order, it works.  
So yeah, it works, but I think this is quite some manipulation.  
  
Is there another way to do this simplier ?  
If not, could the variable type (string, integer, etc.) be set at the "Edit variable" screen ?  
  
Thanks.

---

<div class="post-metadata">

### Author: ![Vincent](https://www.finalbuilder.com/forums/user_avatar/www.finalbuilder.com/vincent/32/938_2.png) [@Vincent](https://www.finalbuilder.com/forums/u/Vincent)
#### Post date: [February 25, 2009, 1:15am UTC](https://www.finalbuilder.com/forums/t/variables-losing-leading-zeros/195/5 "2009-02-25T01:15:04Z")

</div>

Hi Jonathon   
  
 In the next major version of FinalBuilder variables will be typed. For now you will have to resort to script to force the type to string :   
  
 FBVariables.MyStringInt = “0001”   
  
 The other thing you can change, is create a second variable, e.g. mystring and set that using the SetVariable action, and have the default value of your macro action use that second variable , so the default value for your macro will be %mystring%   
  
 HTH
