Main Content

setPreSaveFcn

Class: slreq.ReqSet
Package: slreq

Assign PreSaveFcn callback script

Syntax

setPreSaveFcn(rs,callbackScript)

Description

setPreSaveFcn(rs,callbackScript) assigns the script specified by callbackScript as the PreSaveFcn callback script for the requirement set rs.

Input Arguments

expand all

Requirement set, specified as an slreq.ReqSet object.

Name of the script to register as the PreSaveFcn callback for the requirement set, specified as a string scalar or 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 a 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.

slreqShortestPathProjectStart;

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