I am currently involved in a reverse engineering project.
The model is out of synch with the code. However, the model
does contain some documentation that we do not want to lose.
In order to be able to copy the comments from the existing model's
classes to the reverse engineered model's classes, I am attempting
to rename all the classes in the model that could get replaced
by the r.e. classes (i.e. - add "_old" suffix). After this works,
I will write a script to copy the comments.
However, this simple script to add a suffix to the end of all
classes not already assigned to a module crashes Rose2002
after executing for a while. It crashes where the new name
of the class is assigned to the class.
Here is the script. Any thoughts ?
Any suggestions for other approaches are also welcome.
----------------------------------------------
Dim tempName As String * 20
Function AddSuffixToClasses( ByVal thisCategory As Category ) As Boolean
Dim nextCategoryColl As CategoryCollection
Dim nextClassesColl As ClassCollection
Dim nextCategory As Category
Dim myClass As Class
Dim moduleColl As ModuleCollection
Dim done As Boolean
Set nextCategoryColl = thisCategory.Categories
Set nextClassesColl = thisCategory.Classes
Print "Category name: "; thisCategory.Name
'For all classes in this category, add "_old" suffix
Print "nextClassesColl.Count = "; nextClassesColl.Count
For i% = nextClassesColl.Count To 1 Step -1
Set myClass = nextClassesColl.GetAt(i%)
Set moduleColl = myClass.GetAssignedModules()
If moduleColl.Count = 0 Then
tempName = myClass.Name
Print "class name before = "; tempName
'If tempName = "NoiseFloor_impl" Then
' done = false
'End If
tempName = myClass.Name + "_old"
Print "class name after = "; tempName
thisCategory.Classes.GetAt(i%).Name = tempName
End If
Next i%
'For all children categories, call this function recursively
Print "nextCategoryColl.Count = "; nextCategoryColl.Count
For j% = 1 To nextCategoryColl.Count Step 1
done = AddSuffixToClasses(nextCategoryColl.GetAt(j%))
Next j%
AddSuffixToClasses = True
End Function
Sub Main
'Add the "_old" suffix to all classes not assigned to a module.
'This is a neccessary step before reverse engineering
'the code. After the r.e. is done, the comments from the "old"
'versions of the classes will be copied to the r.e. version of
'the class
Dim classColl As ClassCollection
Dim catColl As CategoryCollection
Dim nextCat As Category
Dim done As Boolean
Viewport.open
'Get list of top level categories
Set catColl = RoseApp.CurrentModel.RootCategory.Categories
For i% = 1 To catColl.Count Step 1
Set nextCat = catColl.GetAt(i%)
Select Case nextCat.Name
Case "ASIP", "AtcSecurityModuleV1","CFasip", "WEBSERVER"
done = AddSuffixToClasses(nextCat)
Case Else
Print "not an app category"
End Select
Next i%
End Sub
Bob Beck
Assurance Technology
Voice: 321-727-8890
Fax: 321-727-8964
E-mail: [EMAIL PROTECTED]
************************************************************************
* Rose Forum is a public venue for ideas and discussions.
* For technical support, visit http://www.rational.com/support
* Only plain-text messages are supported.
* HTML or Rich-Text messages may be rejected.
*
* Post or Reply to: [EMAIL PROTECTED]
* Subscription Requests: [EMAIL PROTECTED]
* Archive of messages:
* http://www.rational.com/support/usergroups/rose/rose_forum.jsp
* Other Requests: [EMAIL PROTECTED]
*
* To unsubscribe from the list, please send email
* To: [EMAIL PROTECTED]
* Subject: <BLANK>
* Body: unsubscribe rose_forum
*************************************************************************