Create and Execute a Script
You can create and execute scripts in the Modelica Scripting window.
-
From the
Behavior Tools section of the
action bar,
click
Modelica Scripting
.
Tip: You can also access this command from the Simulation section of the action bar. The Modelica Scripting window appears.
-
To create a command in the script:
-
Type or insert the command or function in the lower line
(command input line) of the
Modelica Scripting window.
Tips: - You can insert a
function call by right-clicking and selecting
Insert Function Call, and edit an
existing function call by right-clicking and selecting
Edit Function Call. See
Inserting a Function Call and
Editing an Existing Function Call.
Note: Many useful functions are available in the library DymolaCommands,
- To display the
description of a function behavior, type:
- for a short
description:
help functionName
(example:help importFMU
), and press Enter. - for a longer
description, that may include examples:
document("functionName")
(example:document("importFMU")
), and press Enter.
- for a short
description:
- An earlier executed command is available using "arrow up" in the command input line.
- Right-clicking, the context menu contains also common features like copy/paste.
- You can insert a
function call by right-clicking and selecting
Insert Function Call, and edit an
existing function call by right-clicking and selecting
Edit Function Call. See
Inserting a Function Call and
Editing an Existing Function Call.
-
Press
Enter.
The command is displayed and run in the upper part of the window.
-
Type or insert the command or function in the lower line
(command input line) of the
Modelica Scripting window.
-
To save the script:
- Right-click in the upper part of the window and select Copy All Commands.
- Using the Modelica Script Editor, open a new script. See Creating a New Script.
- Paste the commands in this script.
- Save the script using the Modelica Script Editor. See Saving a Script.
The script is saved.Note: If you want to directly use the commands of the script in a function, you can directly paste the commands in a function. -
To execute a script, you can use the function call
RunScript(ScriptName)
.The script is executed; commands and results are displayed in the upper pane of the Modelica Scripting window.