|
#1
|
|||
|
|||
create macro with a fixed size
I need to create a macro for a build number with a fixed size of 4 digits: e.g. 0000
my current project macro is: Macro name: PRODUCT_BUILD_NUMBER value 0000 (my initial value) The increment step is: [%PRODUCT_BUILD_NUMBER%+0001] the result is: 1 (leading zeroes are suppressed) When the macro is incremented by 1, I would like the result to be: 0001, 0002, 0003, etc . with leading zeroes intact. It seems simple, but I cannot find a way to format the value. It always suppresses the leading zeroes. TIA |
#2
|
|||
|
|||
[vbld_PadLeft(CStr(%PRODUCT_BUILD_NUMBER%+1),4,"0")]
|
#3
|
|||
|
|||
create macros with fixed size
Thanks for the fast response, however, although the solution seemed to work the first time and created the result I wanted: 0001 , there were two spaces (or nulls) in the macro following the 0001. When I ran the increment step the second time to increment the macro to 0002, I got the following error:
******************************************* 10/9/2008 5:07:04 PM: Building project step 'Increment_macro_number'... Error expanding macros or script in property MacroValue: <Error at Line 1, Column 23 (Expected ')') Code: vbld_PadLeft(CStr(0001> 10/9/2008 5:07:04 PM: Step 'Increment_macro_number' failed *********************************************** When I went back to the Macro "PRODUCT_VERSION_NUMBER" and trimmed the trailing spaces(nulls, blocks?), the increment solution worked and the result was 0002, however, again there were spaces or nulls trailing the 0002. Is there a way to eliminate or trim the spaces (nulls or blocks)? TIA |
#4
|
|||
|
|||
Perhaps there is a trailing newline character following the script expression?
|
#5
|
|||
|
|||
You're right, a newline(two trailing blocks) is being added to the macro and is causing the error, but I can't find where the newline character is being invoked. Is there some way to trim the macro of the newline character after the fact?
Thanks in advance. |
#6
|
|||
|
|||
Assuming a temporary macro named PRODUCT_BUILD_NUMBER with the build number in 0000 form and a trailing space, a Run Script step (VBScript) with this code would remove any trailing space(s).
Set m = vbld_TempMacro("PRODUCT_BUILD_NUMBER") m.Value = Left(m.Value, 4) The attached sample increments and logs the build number macro from 0001 to 0100 without adding a trailing newline. |
#7
|
|||
|
|||
Thanks, it worked. My old Macro step somehow had a "newline" character embedded within it. When I deleted the entire macro step and created a new one with the macro value:
[vbld_PadLeft(CStr(%PRODUCT_BUILD_NUMBER%+1),4,"0")], the newline character was eliminated and the increment number was correct. Thanks for the solution! |
Thread Tools | |
Display Modes | Rate This Thread |
|
|