To open an existing script Select the Tools:Open Script menu command. Click to select the name of the script. Click the Open button. To create a new script Select the Tools:New Script menu command.
To run a script interactively Create a new script or open an existing script. Click the Start button (green triangle). To save a script in compiled form Create a new script or open an existing script. Select the Debugger:Compile menu command. Enter the name of the compiled script. Click the Save button.
Main() is the first procedure to execute no matter where it is located in the script.
This script may be found on your Course Exercise Models disk. It is called “Print Packages and Class Names.ebs”.
A script can be written to change the names of all classes in the model to enforce naming conventions.
This script may be found on your Course Exercise Models disk. It is called “Prefix.ebs”.
This script may be found on your Course Exercise Models disk. It is called “Add Package with One Class.ebs”.
The solution script may be found on your Course Exercise Models disk. It is called “Add Package with Multiple Classes.ebs”.
Introduction to Rational Rose 98i Module 11: RoseScript
Problem: How do you print out all of the names of all classes in the model?
Print Package and Class Names Script 'The Main statement defines the subroutine where execution begins Sub Main 'Open the Viewport window Viewport.open 'Pass the current open model to the DumpModel subroutine DumpModel RoseApp.CurrentModel 'End the subroutine End Sub
A statement that declares a constant for use within the current script
Const prefix$ As String = “Rose98”
Set prefix$ to the string “Rose98”
Left$ (string, length)
A function that returns a string that contains the leftmost NumChars characters contained in the input string
Return the leftmost character in string
The Prefix Script ' Definition of the prefix Const Prefix$ = "Rose98" Sub Main ' Declare local variables Dim theClasses As ClassCollection Dim theClass As Class ' Set the class collection to all the classes in the model Set theClasses = RoseApp.CurrentModel.GetAllClasses ()