CodeGuru
Earthweb Search
Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
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
















RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

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)


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES