I am new to VBScript, however, created a macro that should increment my version number in VC++ every time I compile. I want my macro to skip to the next char when my version count exceeds 9 (i.e. if version is 1.0.0.9, on my next build I would like for it to be 1.0.1.0). I am having problem accomplishing this task can someone help me? PLEASE?!!!! Example of my macro is below...
Sub ReplaceText(selection, count, incrementby)
'selection -- represents the TextSelection object
'count -- represents the position of the version number to be incremented
'incrementby -- represents a number that will be added to the existing version number
Dim str
selection.WordRight dsMove, count
selection.WordRight dsExtend, 1
str = selection.Text
str = str + incrementby
selection.Text = str
End Sub
Sub Application_BuildFinish(numError, numWarning)
'This event will be triggered after every build of a project
'You can check numError and/or numWarning to determine if you want to continue
'If numError <> 0 Then
'exit sub
'Obtain the full path of the active project
Dim full_path
full_path = GetProjectDir(ActiveProject.FullName)
'full_path = full_path & "versionno.h"
full_path = "L:\\certs\\fac\\src\\consolee\\versionno.h"
'Open the VersionNo.h file
Documents.Open full_path
'Obtain the TextSelection object
Dim selection
set selection = ActiveDocument.Selection
selection.StartOfDocument
'Increment the version information
selection.LineDown
ReplaceText selection, 9, 1
selection.LineDown
selection.StartOfLine
ReplaceText selection, 9, 1
selection.LineDown
selection.StartOfLine
ReplaceText selection, 10, 1
selection.LineDown
selection.StartOfLine
ReplaceText selection, 10, 1
ActiveDocument.Save
ActiveDocument.Close
End Sub
Sub ReplaceText(selection, count, incrementby)
'selection -- represents the TextSelection object
'count -- represents the position of the version number to be incremented
'incrementby -- represents a number that will be added to the existing version number
Dim str
selection.WordRight dsMove, count
selection.WordRight dsExtend, 1
str = selection.Text
str = str + incrementby
selection.Text = str
End Sub
Sub Application_BuildFinish(numError, numWarning)
'This event will be triggered after every build of a project
'You can check numError and/or numWarning to determine if you want to continue
'If numError <> 0 Then
'exit sub
'Obtain the full path of the active project
Dim full_path
full_path = GetProjectDir(ActiveProject.FullName)
'full_path = full_path & "versionno.h"
full_path = "L:\\certs\\fac\\src\\consolee\\versionno.h"
'Open the VersionNo.h file
Documents.Open full_path
'Obtain the TextSelection object
Dim selection
set selection = ActiveDocument.Selection
selection.StartOfDocument
'Increment the version information
selection.LineDown
ReplaceText selection, 9, 1
selection.LineDown
selection.StartOfLine
ReplaceText selection, 9, 1
selection.LineDown
selection.StartOfLine
ReplaceText selection, 10, 1
selection.LineDown
selection.StartOfLine
ReplaceText selection, 10, 1
ActiveDocument.Save
ActiveDocument.Close
End Sub