Variables losing leading zeros

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

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

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

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.

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