Main Content

slreq.TextRange

    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.

    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.

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

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

    show(tr);

    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(tr,req);

    Version History

    Introduced in R2022b