Main Content

getPreSaveFcn

Class: slreq.ReqSet
Namespace: slreq

Get contents of PreSaveFcn callback

Since R2022a

Syntax

callback = getPreSaveFcn(rs)

Description

callback = getPreSaveFcn(rs) returns the contents of the PreSaveFcn callback for the requirement set rs.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Output Arguments

expand all

Contents of the PreSaveFcn callback for the requirement set, returned as a character vector.

Examples

expand all

This example shows how to get and set the PreSaveFcn callback for a requirement set.

Add the current folder to the path.

addpath(pwd)

Open the ShortestPath project that contains an algorithm to calculate the shortest path between two nodes on a graph. For more information, see Verify a MATLAB Algorithm by Using Requirements-Based Tests.

openProject("ShortestPath");

Open the shortest_path_tests_reqs requirement set. The requirement set contains test requirements that describe the functional behavior that must be tested by a test case in order to verify the shortest_path algorithm in the project.

testReqs = slreq.open("shortest_path_tests_reqs");

Register the preSaveTestReqs script as the PreSaveFcn callback.

setPreSaveFcn(testReqs,"preSaveTestReqs");

Confirm that the preSaveTestReqs script is the PreSaveFcn callback for the shortest_path_tests_reqs requirement set.

callbackScript = getPreSaveFcn(testReqs)
callbackScript = 
'preSaveTestReqs'

Save the shortest_path_tests_reqs requirement set to execute the callback.

save(testReqs);

The preSaveTestReqs script saves the current Requirements Editor view settings to a MAT-file called myViewSettings.mat.

type preSaveTestReqs.m
slreq.exportViewSettings("myViewSettings.mat");

Version History

Introduced in R2022a