For Programmers: Free Programming Magazines  


Home > Archive > Fortran > November 2004 > Build no.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Build no.
Dan Holm

2004-11-17, 8:57 am

Hi,
Anoby know how to get an automatic build no. when building an executable
in CVF 6.6C (and/or IVF8.1).
Want to refer to it in a help dialog. I use Winteracter to build the
gui.

Regards,
Dan Holm
--
Alfgam optimering AB
url: http://www.alfgam.se


Jugoslav Dujic

2004-11-17, 8:57 am

Dan Holm wrote:
| Hi,
| Anoby know how to get an automatic build no. when building an executable
| in CVF 6.6C (and/or IVF8.1).
| Want to refer to it in a help dialog. I use Winteracter to build the
| gui.

I use a "IncResVersion" macro. It increments the build number of the
"Version" resource in your .rc file and builds the application every
time you run it. This is the modified version of a macro I found
here:

http://www.codeguru.com/Cpp/V-S/devstudio_macros/

So:

1) Go to Tools/Macro/Edit and paste the code below into the
MyMacro.dsm code
2) Go to Tools/Customize and add the macro to "Build" menu
and/or assign a key combination to it (I keep both "Build"
and "IncResVersion" menu items in cases I don't have/don't
want the update of version resource)
3) Add a "Version" resource to your resource (if you don't have
one)
4) The .rc file must be opened in order for the macro to run
successfully.

The version information can be viewed from Explorer->Properties->
Version tab. If you want to retrieve it programmatically, see here:

http://softwareforums.intel.com/ids...message.id=4032

HTH,
--
Jugoslav
___________
www.geocities.com/jdujic

Please reply to the newsgroup.
You can find my real e-mail on my home page above.

'---------------------------------------
Sub IncResVersion()
'DESCRIPTION: Build active project and increase version counters in rc script.
'(c)'98 Th. Mahler and parts by LJP. Modified by N.E. Powroz -- Dec 1999
'Modified by Peter Smolders 03 Jan 2000
'Modified by Jugoslav Dujic 2002

Dim strMonth
Dim strDay
Dim strYear
Dim strHour
Dim strMinute
Dim strSecond

Dim Wnd
Dim strOldFileVersion
Dim strNewFileVersion
Dim strOldProductVersion
Dim strNewProductVersion
Dim strSelection
Dim strTemp

Dim documentObject
Dim bFound

' open the project's resource script:

bResult = MsgBox( "Increase Build Number?", vbYesNo )
if bResult=vbYes then

strTemp = ActiveProject.FullName

bFound = False
For Each documentObject in Application.Documents
Wnd = Right(documentObject.FullName,2)
if (Wnd = "rc") then
Wnd = documentObject.FullName
bFound = True
exit for
end if
Next

If (Not bFound) then
MsgBox "Please open .rc file."
Else
' SAVE BACK-UP OF FILE >>>>
Documents.Open (Wnd)
documentObject.Active = True
' ActiveDocument.Save (Wnd+"~")

ActiveDocument.Close()
Documents.Open Wnd, "Text"

'Go to 2nd line in rc file, delete it, and get current time/date
ActiveDocument.Selection.GoToLine 2
ActiveDocument.Selection.SelectLine
ActiveDocument.Selection.Delete

strMonth = CStr(DatePart("m", Now))
strDay = CStr(DatePart("d", Now))
strYear = CStr(DatePart("yyyy", Now))
strHour = CStr(DatePart("h", Now))
strMinute = CStr(DatePart("n", Now))
strSecond = CStr(DatePart("s", Now))

'write current date/time and add newline - formatted for USA
ActiveDocument.Selection.Text ="// Last compiled "+strDay +
"."+strMonth+"."+strYear+" at "+strHour+":"+strMinute+":"+strSecond + vbCrLf

' find line with FileVersion Information:
ActiveDocument.Selection.FindText "FILEVERSION", dsMatchForward +
dsMatchFromStart + dsMatchCase + dsMatchWord

' move to eol and then to end of build number:
ActiveDocument.Selection.EndOfLine

' mark Build Number and store in strSelection
ActiveDocument.Selection.WordLeft dsExtend, 1

Set strSelection = ActiveDocument.Selection
strOldFileVersion = strSelection.Text
strNewFileVersion = strOldFileVersion + 1

' Replace file entry
strSelection.Text = strNewFileVersion

' info block
ActiveDocument.Selection.FindText "VALUE ""FileVersion"",",
dsMatchForward + dsMatchFromStart + dsMatchCase

' move to eol and then to end of build number:
ActiveDocument.Selection.EndOfLine
ActiveDocument.Selection.CharLeft dsMove, 3

' mark Build Number and store in strVersion
ActiveDocument.Selection.WordLeft dsExtend, 1

Set strSelection = ActiveDocument.Selection
strSelection.Text = strNewFileVersion

ActiveDocument.Save()
End If
End If
ExecuteCommand "Build"
' ActiveDocument.Close()

End Sub

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com