Clone of UAS2 @ https://github.com/drudgedance/uas2

UAS2_ver.dsm 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. '------------------------------------------------------------------------------
  2. 'FILE DESCRIPTION: For automatic increment of build number.
  3. '------------------------------------------------------------------------------
  4. Function GetProjectDir(FullName)
  5. 'VC++ doesn't provide any method for getting the path of the active project
  6. 'See the VB Script reference for more information on the VB Script functions
  7. 'used in this function
  8. Dim proj_path
  9. proj_path = Split(StrReverse(FullName),"\",-1,1)
  10. Dim count
  11. count = UBound(proj_path)
  12. Dim full_path
  13. full_path = ""
  14. Dim i
  15. for i = 1 to count
  16. full_path = full_path & "\" & proj_path(i)
  17. next
  18. GetProjectDir = StrReverse(full_path)
  19. End Function
  20. Sub ReplaceText(selection, count, incrementby)
  21. 'selection represents the TextSelection object
  22. 'count represents the position of the version number to be incremented
  23. 'incrementby represents a number that will be added to the existing version number
  24. selection.WordRight dsMove, count
  25. selection.WordRight dsExtend, 1
  26. Dim str
  27. str = selection.Text
  28. str = str + incrementby
  29. selection.Text = str
  30. End Sub
  31. Sub Application_BuildFinish(numError, numWarning)
  32. 'This event will be triggered after every build of a project
  33. 'You can check numError and/or numWarning to determine if you want to continue
  34. 'If numError <> 0 Then
  35. 'exit sub
  36. 'Obtain the full path of the active project
  37. Dim full_path
  38. full_path = GetProjectDir(ActiveProject.FullName)
  39. full_path = full_path & "versionno.h"
  40. 'Open the VersionNo.h file
  41. Documents.Open full_path
  42. 'Obtain the TextSelection object
  43. Dim selection
  44. set selection = ActiveDocument.Selection
  45. selection.StartOfDocument
  46. 'Increment the version information
  47. ReplaceText selection, 9, 1
  48. selection.LineDown
  49. selection.StartOfLine
  50. ReplaceText selection, 9, 1
  51. selection.LineDown
  52. selection.StartOfLine
  53. ReplaceText selection, 10, 1
  54. selection.LineDown
  55. selection.StartOfLine
  56. ReplaceText selection, 10, 1
  57. ActiveDocument.Save
  58. ActiveDocument.Close
  59. End Sub