Main Content

getAttribute

Class: slreq.Link
Package: slreq

Get link property values

Syntax

val = getAttribute(myLink,propertyName)

Description

val = getAttribute(myLink,propertyName) returns the value of the link property, propertyName, for the link myLink. The property can be a built-in property, a custom attribute, or a stereotype property.

Note

To return the value of a stereotype property, you must pass the fully qualified name of the property. For example, the fully qualified name for a property called Status in a stereotype called myStereotype in a profile called myProfile is myProfile.myStereotype.Status.

Input Arguments

expand all

Link, specified as an slreq.Link object.

Link property name, specified as a string scalar or character vector.

Example: "Description"

Output Arguments

expand all

Link property value, returned as a:

  • String scalar

  • Character array

  • boolean

  • datetime

  • single

  • double

  • int8

  • int16

  • int32

  • int64

  • uint8

  • uint16

  • uint32

  • uint64

  • enumeration

The data type depends on the type of the built-in property, custom attribute, or stereotype property.

Examples

expand all

This example shows how to get the attribute value of a specified custom attribute for a link.

Load the crs_req requirement files, which contain links for a cruise control system. Find the link set.

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

Create a links array containing all the links from link set ls. Get one link from the array. Get the attribute value of the custom attribute called Target Speed Change, which tracks whether linked requirements are related to incrementing or decrementing the speed.

linksArray = find(ls);
myLink = linksArray(7);
val = getAttribute(myLink,'Target Speed Change')
val = 
'Decrement'

Cleanup

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

slreq.clear;
bdclose all;

Tips

Version History

Introduced in R2020b