Methods (Profile)

Methods are written in VBScript and perform actions on objects when they are invoked by other extensions, such as menu items or form buttons.

  1. Right-click a metaclass, stereotype, or criterion and select New > Method.
  2. Enter the following properties as appropriate:

    Property

    Description

    Name

    Specifies the name of the method.

    Comment

    Provides additional information about the method.

  3. Click the Method Script tab, and enter the VBscript. If appropriate, you can reuse functions on the Global Script tab.

    For more information on defining a script and using the Global Script tab, see Example: PDM Custom Check and Global Script (Profile).

    The following example, created under the Class metaclass, converts classes into interfaces by copying basic class properties and operations, deleting the class (to avoid namespace problems), and creating the new interface.

    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
    Note: This script does not deal with other class properties, or with interface display, but a method can be used to launch a custom dialog box to ask for end-user input before performing its action (see Example: Opening a Dialog Box from a Menu).
  4. Click Apply to save your changes.