addAttribute

Class: slreq.LinkSet
Package: slreq

Add custom attribute to link set

Syntax

addAttribute(myLinkSet,name,type)
addAttribute(myLinkSet,name,'Checkbox','DefaultValue',value)
addAttribute(myLinkSet,name,'Combobox','List',options)
addAttribute(myLinkSet,___,'Description',descr)

Description

addAttribute(myLinkSet,name,type) adds a custom attribute with the name specified by name and the custom attribute type specified by type to the link set myLinkSet.

addAttribute(myLinkSet,name,'Checkbox','DefaultValue',value) adds a Checkbox custom attribute with the name specified by name and the default value specified by value to the link set myLinkSet.

addAttribute(myLinkSet,name,'Combobox','List',options) adds a Combobox custom attribute with name specified by name, and the list options specified by options to the link set myLinkSet.

addAttribute(myLinkSet,___,'Description',descr) adds a custom attribute with the name specified by name, the type specified by type, and the description specified by descr to the link set myLinkSet.

Input Arguments

expand all

Link set, specified as an slreq.LinkSet object.

Custom attribute name, specified as a character array.

Custom attribute type, specified as a character array. The valid custom attribute types are 'Edit', 'Checkbox', 'Combobox', and 'DateTime'.

Custom attribute description, specified as a character array.

Checkbox default value, specified as a logical 1 (true) or 0 (false).

Combobox list options, specified as a cell array. The list of options is valid only if 'Unset' is the first entry. 'Unset' indicates that the user hasn't chosen an option from the combo box. If the list does not start with 'Unset', it will be automatically appended as the first entry.

Example: {'Unset','A','B','C'}

Examples

expand all

This example shows how to add a custom attribute to of all four available types, Edit, Checkbox, Combobox, and DateTime, and how to add a custom attribute with a description.

Add an Edit Custom Attribute

Load the crs_req requirement files, which describes for a cruise control system. Find a link set in the files and assign it to a variable.

slreq.load('crs_req');
ls = slreq.find('Type','LinkSet');

Add an Edit custom attribute. Confirm that the attribute added by using inspectAttribute.

addAttribute(ls,'MyEditAttribute','Edit');
atrb = inspectAttribute(ls,'MyEditAttribute')
atrb = struct with fields:
           name: 'MyEditAttribute'
           type: Edit
    description: ''

Add a Checkbox Custom Attribute

Add a Checkbox custom attribute with the default value true. Confirm that the attribute was added successfully by using inspectAttribute.

addAttribute(ls,'MyCheckbox','Checkbox','DefaultValue',true);
atrb2 = inspectAttribute(ls,'MyCheckbox')
atrb2 = struct with fields:
           name: 'MyCheckbox'
           type: Checkbox
    description: ''
        default: 1

Add a Combobox Custom Attribute

Add a ComboBox custom attribute with the options Unset, A, B, and C. Confirm that the attribute was added successfully by using inspectAttribute.

addAttribute(ls,'MyCombobox','Combobox','List',{'Unset','A','B','C'});
atrb3 = inspectAttribute(ls,'MyCombobox')
atrb3 = struct with fields:
           name: 'MyCombobox'
           type: Combobox
    description: ''
           list: {'Unset'  'A'  'B'  'C'}

Add a DateTime Custom Attribute

Add a DateTime custom attribute. Confirm that the attribute was added successfully by using inspectAttribute.

addAttribute(ls,'MyDateTime','DateTime');
atrb4 = inspectAttribute(ls,'MyDateTime')
atrb4 = struct with fields:
           name: 'MyDateTime'
           type: DateTime
    description: ''

Add a Custom Attribute with a Description

Add an Edit custom attribute. Add a description to the custom attribute. Confirm that the attribute was added successfully by using inspectAttribute.

addAttribute(ls,'MyEditAttribute2','Edit','Description',...
    'You can enter text as the custom attribute value.');
atrb5 = inspectAttribute(ls,'MyEditAttribute2')
atrb5 = struct with fields:
           name: 'MyEditAttribute2'
           type: Edit
    description: 'You can enter text as the custom attribute value.'

Add a ComboBox custom attribute with the options Unset, A, B, and C. Add a description to the custom attribute. Confirm that the attribute was added successfully by using inspectAttribute.

addAttribute(ls,'MyCombobox2','Combobox','List',{'Unset','A','B','C'},'Description',...
    'This combo box attribute has 4 options.');
atrb6 = inspectAttribute(ls,'MyCombobox2')
atrb6 = struct with fields:
           name: 'MyCombobox2'
           type: Combobox
    description: 'This combo box attribute has 4 options.'
           list: {'Unset'  'A'  'B'  'C'}

Cleanup

Clean up commands. Clear the open requirement sets without saving changes and close the open models without saving changes.

slreq.clear;
bdclose all;
Introduced in R2020b