Main Content

discardChanges

Discard changes to data dictionary

Description

discardChanges(dictionaryObj) discards all changes made to the specified data dictionary since the last time changes to the dictionary were saved using the saveChanges function. discardChanges also discards changes made to referenced data dictionaries. The changes to the target dictionary and its referenced dictionaries are permanently lost.

example

Examples

collapse all

Create a Simulink.data.Dictionary object representing the data dictionary myDictionary_ex_API.sldd and assign the object to variable myDictionaryObj.

myDictionaryObj = Simulink.data.dictionary.open('myDictionary_ex_API.sldd')
myDictionaryObj = 

  Dictionary with properties:

          DataSources: {'myRefDictionary_ex_API.sldd'}
    HasUnsavedChanges: 0
           NumberOfEntries: 4

Make a change to myDictionary_ex_API.sldd by adding an entry named myNewEntry with value 237. View the HasUnsavedChanges property of myDictionaryObj to confirm a change was made.

dDataSectObj = getSection(myDictionaryObj,'Design Data');
addEntry(dDataSectObj,'myNewEntry',237);
myDictionaryObj
myDictionaryObj = 

  Dictionary with properties:

          DataSources: {'myRefDictionary_ex_API.sldd'}
    HasUnsavedChanges: 1
           NumberOfEntries: 5

Discard all changes to myDictionary_ex_API.sldd. The HasUnsavedChanges property of myDictionaryObj indicates changes were discarded.

discardChanges(myDictionaryObj)
myDictionaryObj
myDictionaryObj = 

  Dictionary with properties:

          DataSources: {'myRefDictionary_ex_API.sldd'}
    HasUnsavedChanges: 0
           NumberOfEntries: 4

Input Arguments

collapse all

Target data dictionary, specified as a Simulink.data.Dictionary object. Before you use this function, represent the target dictionary with a Simulink.data.Dictionary object by using, for example, the Simulink.data.dictionary.create or Simulink.data.dictionary.open function.

Alternatives

You can use the Model Explorer window to discard changes to data dictionaries. See View and Revert Changes to Dictionary Entries for more information.

Version History

Introduced in R2015a