Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] General Discussion
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 10-09-2008, 03:11 PM
Joe G Joe G is online now
Registered User
 
Join Date: 10-09-2008
Posts: 6
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
Reply With Quote
  #2  
Old 10-09-2008, 03:17 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,015
[vbld_PadLeft(CStr(%PRODUCT_BUILD_NUMBER%+1),4,"0")]
Reply With Quote
  #3  
Old 10-09-2008, 04:40 PM
Joe G Joe G is online now
Registered User
 
Join Date: 10-09-2008
Posts: 6
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
Reply With Quote
  #4  
Old 10-09-2008, 04:54 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,015
Perhaps there is a trailing newline character following the script expression?
Reply With Quote
  #5  
Old 10-10-2008, 02:20 PM
Joe G Joe G is online now
Registered User
 
Join Date: 10-09-2008
Posts: 6
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.
Reply With Quote
  #6  
Old 10-10-2008, 02:50 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,015
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.
Attached Files
File Type: bld padbuildnum.bld (878 Bytes, 984 views)
Reply With Quote
  #7  
Old 10-10-2008, 04:23 PM
Joe G Joe G is online now
Registered User
 
Join Date: 10-09-2008
Posts: 6
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!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 08:18 PM.


Copyright © 1999-2023 Kinook Software, Inc.