Main Content

Simulink.data.dictionary.closeAll

Close all connections to all open data dictionaries

Description

Simulink.data.dictionary.closeAll attempts to close all connections to all data dictionaries that are open. For example, if you create objects, such as Simulink.data.Dictionary, that refer to a dictionary, that dictionary is open.

Some commands and functions, such as Simulink.data.dictionary.cleanupWorkerCache, cannot operate when dictionaries are open. It is a best practice to close each connection individually by using functions and methods such as the close method of a Simulink.data.Dictionary object. To find dictionaries that are open, use Simulink.data.dictionary.getOpenDictionaryPaths. However, you can use this function to close all connections to all dictionaries.

You can also use this function to close dictionaries in a shutdown script that is part of a project.

Simulink.data.dictionary.closeAll(dictFileName) closes all connections to the dictionary named dictFileName. If you open multiple dictionaries that use this file name (for example, if the dictionaries have different file paths), the function closes all connections to all of the dictionaries.

You cannot specify dictFileName as a full file path such as 'C:\temp\myDict.sldd'.

Simulink.data.dictionary.closeAll(___,unsavedAction) closes all connections to the target dictionaries by discarding or saving unsaved changes. You can choose whether to save or discard all changes to all of the target dictionaries.

example

Examples

collapse all

Discard any unsaved changes. All of the entries in the dictionaries revert to the last saved state.

Simulink.data.dictionary.closeAll('-discard')

Open multiple connections to a data dictionary, make a change, and close all of the connections by discarding the unsaved change.

At the command prompt, open a data dictionary by creating a Simulink.data.Dictionary object that refers to the dictionary.

For example, open the Using a Data Dictionary to Manage the Data for a Fuel Control System example data dictionary.

openExample('simulink_automotive/UseDDForFuelContSysExample')
dictObj = Simulink.data.dictionary.open('sldemo_fuelsys_dd.sldd');

Display the dictionary in the Model Explorer

show(dictObj)

You now have two connections to this dictionary: The Simulink.data.Dictionary object and the Model Explorer.

Make a change to the dictionary by adding an entry.

dDataSectObj = getSection(dictObj,'Design Data');
addEntry(dDataSectObj,'myEntry',5.2);

The Simulink.data.dictionary.Section object dDataSectObj is a third connection to the dictionary.

Close the connections to the dictionary. Discard the unsaved change.

Simulink.data.dictionary.closeAll('sldemo_fuelsys_dd.sldd','-discard')

The dictionary no longer appears as a node in the Model Hierarchy pane of the Model Explorer. The Simulink.data.Dictionary object dictObj is disconnected from the dictionary. You cannot interact with the dictionary by using the Simulink.data.dictionary.Section object dDataSectObj.

Clear the objects that referred to the dictionary.

clear dictObj dDataSectObj

Input Arguments

collapse all

File name of target data dictionary or dictionaries, specified as a character vector. Use the file extension sldd.

Example: 'myDict.sldd'

Data Types: char

Action for unsaved changes, specified as '-discard' (to discard changes) or '-save' (to save changes). If you call Simulink.data.dictionary.closeAll without the unsavedAction argument, Simulink® reports an error if the data dictionary has unsaved changes.

Tips

A data dictionary is open if any of these conditions are true:

  • The dictionary appears as a node in the Model Hierarchy pane of the Model Explorer. To close this connection to the dictionary, right-click the node in Model Explorer and select Close. Alternatively, use the hide method of a Simulink.data.Dictionary object.

  • You created an object of any of these classes that refer to the dictionary:

    • Simulink.data.Dictionary

    • Simulink.data.dictionary.Section

    • Simulink.data.dictionary.Entry

    To close these connections to the dictionary, use the close method of the Simulink.data.Dictionary object or clear the object. Clear the Simulink.data.dictionary.Section and Simulink.data.dictionary.Entry objects.

  • A model that is linked to the dictionary is open. To close this connection to the dictionary, close the model.

Version History

Introduced in R2016a