Main Content

slreq.TextRange

Line range

Since R2022b

    Description

    Use slreq.TextRange objects to describe lines of code in a MATLAB® code or plain-text external code file.

    Creation

    There are several ways to create an slreq.TextRange object:

    Properties

    expand all

    This property is read-only.

    Name of the file containing the lines of code, returned as a character vector.

    This property is read-only.

    Line range identifier, returned as a character vector. Requirements Toolbox™ generates this property value automatically for each slreq.TextRange object. If you create more than one slreq.TextRange object from the same file, each object has a unique Id property value.

    This property is read-only.

    Domain of the artifact that contains the linkable object, returned as a character vector.

    This property is read-only.

    MATLAB Function block SID, returned as a character vector.

    This property is empty for line ranges in MATLAB code files or other plain-text external code files, such as C files.

    Object Functions

    deleteLinksDelete links for line ranges
    getLineRangeGet line numbers for line range
    getLinksGet links for line range
    getTextGet contents of line range
    removeDelete unused line ranges
    setLineRangeSet line numbers for line range
    showOpen and highlight line range in MATLAB Editor

    Examples

    collapse all

    This example shows how to create an slreq.TextRange object and link it to a requirement.

    Create an slreq.TextRange object that corresponds to line numbers 1 and 2 in the myAdd function.

    lineRange = slreq.createTextRange("myAdd.m",[1 2]);

    View the slreq.TextRange object in the MATLAB® Editor.

    show(lineRange);

    Load the myAddRequirements requirement set.

    rs = slreq.load("myAddRequirements");

    Get a handle to the requirement with the summary Add u and v.

    req = find(rs,Summary="Add u and v");

    Create a link from the slreq.TextRange object to the requirement.

    myLink = slreq.createLink(lineRange,req);

    Version History

    Introduced in R2022b