Features Creation

You can describe the purpose or the usage of OTScript classes, attributes, and methods, which correspond to OTScript features.

The first thing to do when creating a feature is to expose the OTScript feature to the report template editor using the -doc option.

This page discusses:

Category and Label

The OTScript feature can be associated with a category. You can specify a label for a feature.

Note: If no category is defined, the default category is Extensions.

You can also declare the category in the label.

METHOD ... CATEGORY "Customer" LABEL "Quantity"; // the category is Customer and label is Quantity
METHOD ... LABEL "Quantity"; // the category is Extensions and label is Quantity
METHOD ... LABEL "Customer,Quantity"; // the category is Customer and label is Quantity

Class Pattern

The following pattern enables you to define a class:

Syntax
CLASS <class_name> -doc : <type>;

Attribute Pattern

The following pattern enables you to define an attribute:

Syntax

ATTRIBUTE <class_name>.<attribute_name> -doc : <type> CATEGORY <category> LABEL <label>;

Method Pattern

You can provide a help text for methods:METHOD ... LABEL "Format Time" HELPTEXT "See documentation of TIMETOSTR";.

The following pattern enables you to define a method:

Syntax

METHOD <type_name>.<method_name>() -doc : {
...
<code>
...
} LABEL "<category>,<label>"
HELPTEXT "<tooltip>";

Description

Parameter Description
type_name

The internal receiver type name. This name is visible in the tooltip when you hover over the type in the Data tab.

method_name

The internal name of the method. This name is visible in the tooltip when you hover over the method in the Data tab.

code

The code of the method. The last line corresponds to the returned element.

category

The category name, which is visible in the Data tab.

label

The method name, which is visible in the Data tab.

tooltip

The tooltip displayed when you hover over in the Data tab.

-doc

The -doc option lets you expose the OTScript method to Report Template Design. So the method becomes visible. To use this option, the label is mandatory.

Example

This example shows a method, which counts the number of requirements that are refined.

Satisfy the following prerequisites:

  • Create a template such as the Getting Started template with a specification folder as an input parameter.
  • Insert requirement specifications containing requirements in the specification folder.
  • Create a system scope to cover the requirements of the requirement specification by other requirements of another requirement specification.

Insert the following code in the OTScript tab of your template. This code creates a method named Number of refined requirements, which is added to the Customer category:

PACKAGE PLM;
METHOD `Requirement Group`.getDerivedRequirementsCount() -doc : {
     TMP reqSpecs := `rel_Requirement Group Content`.`to_Requirement Specification`;
     $CNT(reqSpecs.getAllRequirements()[$SOME(`rel_Derived Requirement`)])
} CATEGORY "Customer" LABEL "Number of refined requirements"
HELPTEXT "Get the number of requirements that are refined by other requirements";