Main Content

discardChanges

Discard changes to data dictionary entry

Description

example

discardChanges(entryObj) discards all changes made to the data dictionary entry entryObj, a Simulink.data.dictionary.Entry object, since the last time the containing data dictionary was saved using the saveChanges function. The changes to the entry are permanently lost.

Examples

collapse all

Represent the data dictionary entry fuelFlow with a Simulink.data.dictionary.Entry object named fuelFlowObj. fuelFlow is defined in the data dictionary myDictionary_ex_API.sldd.

myDictionaryObj = Simulink.data.dictionary.open('myDictionary_ex_API.sldd');
dDataSectObj = getSection(myDictionaryObj,'Design Data');
fuelFlowObj = getEntry(dDataSectObj,'fuelFlow');

Change the entry fuelFlow by assigning it the new value 493. Confirm a change was made by viewing the Status property of fuelFlowObj.

setValue(fuelFlowObj,493);
fuelFlowObj
fuelFlowObj = 

  Entry with properties:

              Name: 'fuelFlow'
             Value: 493
        DataSource: 'myDictionary_ex_API.sldd'
      LastModified: '2014-Sep-05 13:14:30.661978'
    LastModifiedBy: 'jsmith'
            Status: 'Modified'

Discard all changes to the entry fuelFlow. The Status property of fuelFlowObj shows that changes were discarded.

discardChanges(fuelFlowObj)
fuelFlowObj
fuelFlowObj = 

  Entry with properties:

              Name: 'fuelFlow'
             Value: 237
        DataSource: 'myDictionary_ex_API.sldd'
      LastModified: '2014-Sep-05 13:12:06.099278'
    LastModifiedBy: 'jsmith'
            Status: 'Unchanged'

Input Arguments

collapse all

Target data dictionary entry, specified as a Simulink.data.dictionary.Entry object. Before you use this function, represent the target entry with a Simulink.data.dictionary.Entry object by using, for example, the getEntry function.

Tips

  • You can use the discardChanges function or the saveChanges function with an entire data dictionary, discarding or saving changes to all entries in the dictionary at once. However, only the discardChanges function can additionally operate on individual entries. You cannot use the saveChanges function to save changes to individual entries.

Alternatives

You can use Model Explorer and the Comparison Tool to discard changes to data dictionary entries. See View and Revert Changes to Dictionary Entries for more information.

Version History

Introduced in R2015a