Chapter 4 Managing Profiles


Creating a method

When you create a method, you have to define the method function in the Method Script tab. The Global Script tab is also available and allows you to reuse functions and sub-procedures. This tab is shared with event handlers and transformations.

You type the script of a custom check in the Method Script tab of the method properties. By default, the Method Script tab displays the following script items:

For example, you can create a method for a class that converts classes into interfaces. The following script copies class basic properties and operations, deletes the class to avoid namespace problem and creates the new interface. Note that the script does not deal with other class properties, nor interface display.

Sub %Mthd%(obj)
   ' Convert class to interface

   ' Copy class basic properties
   Dim Folder, Intf, ClassName, ClassCode
   Set Folder = obj.Parent
   Set Intf = Folder.Interfaces.CreateNew
   ClassName = obj.Name
   ClassCode = obj.Code
   Intf.Comment = obj.Comment
   
   ' Copy class operations
   Dim Op
   For Each Op In obj.Operations
      ' ...
      Output Op.Name
   Next

   ' Destroy class
   obj.Delete

   ' Rename interface to saved name
   Intf.Name = ClassName
   Intf.Code = ClassCode
End Sub

Steps To create a method:

  1. Right-click a metaclass, a stereotype or a criterion and select New→Method.

    A method is created.
  2. Type a name in the Name box.
  3. (optional) Type a comment in the Comment box.
  4. Type the script in the Method Script tab.
  5. (optional) Reuse functions stored in the Global Script tab.
  6. Click Apply.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.