CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home >> Visual C++ / C++ >> Visual Studio >> Add-ins & Macros


Sequentially Renumber resource ID's
Rating: none

Corey House (view profile)
August 7, 1998

This macro will take a selection and renumber the resource ID's in sequential order. This comes in very handy when trying to avoid resource conflicts as well as when trying to merge items from one resouce file into another.


' This will assisgn resource ID's to the selected block by starting
' with the resource ID given and then incrementing until the end of
' the selection is reaced.
' (Uncomment the commented lines to process only sourcecode files)

Sub AssignResourceIDToSelection ()

     msg = InputBox ("Enter The resource ID to start From:")

'    TypeOfFile = FileType(ActiveDocument)

'    if TypeOfFile <> dsCPP   Then
'         MsgBox "File Must be of type .c, .cpp, .cxx, .h, .hpp, .hxx"
'    Else
          If msg <> "" Then
               If IsNumeric(msg) Then
                    nCurResourceID = Int(msg)
                    AssignGivenResourceIDToSelection(nCurResourceID)
               End If
          Else
               MsgBox "You MUST enter a resource ID, Aborting"
          End If
'    End if
End Sub


'This function can be integrated with other macros to
'automate the renumbering of resource ID's

Function AssignGivenResourceIDToSelection (ByVal nCurResourceID)

     nStartLine = ActiveDocument.Selection.TopLine
     nEndLine = ActiveDocument.Selection.BottomLine

     ' Debugging messageBox
     ' MsgBox "Start:" + CStr(nStartLine) + " End:" + + CStr(nEndLine)
     For i = nStartLine To nEndLine
          ActiveDocument.Selection.GoToLine i
          ActiveDocument.Selection.FindText "#define", dsMatchForward
          If ActiveDocument.Selection.CurrentLine = i Then
               ' Debugging messageBox
               ' MsgBox "Ext:" + CStr(ActiveDocument.Selection.CurrentLine)
               ActiveDocument.Selection.EndOfLine
               ActiveDocument.Selection.WordLeft dsExtend
               ActiveDocument.Selection = nCurResourceID
               nCurResourceID = nCurResourceID + 1
          End if
     Next

End Function

Updated 21 March 1998

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
*** IT'S GREAT *** - Legacy CodeGuru (04/15/2003)
ID Resequencing with MSDev 7 (2002) - Legacy CodeGuru (10/09/2002)
Wish I had this last week! - Legacy CodeGuru (12/21/2001)
My solve: Sequentially Renumber Resource ID's - Legacy CodeGuru (08/09/2001)
HM files support? - Legacy CodeGuru (08/15/1999)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)