Writing and Playing Scripts
You can edit an inline script attached to a buffer in the script editor. To display this editor, click on the Script Editor icon in the tool bar at the top of the Main window or execute the ShowScriptEditor command.
By default, the script editor appears as part of the Main window, underneath the drawing area. If you want the editor to be displayed in a separate top window, define a panel description for the ScriptEditor panel using the topView property, as shown below:
panel "ScriptEditor" {
topView true;
}
When editing an inline script in the script editor, you do not have to explicitly validate or save it; the script is automatically saved in the .ilv file and read back when you edit your .ilv file again. The inline script you edit is attached to the current buffer. When a buffer is selected, the script editor is updated to edit the corresponding script.
When a container loads your .ilv file, the inline script is also loaded and all the expressions it contains are evaluated. In contrast, when you open an .ilv file in a Views Studio buffer, script expressions are not evaluated.
When you test the currently edited application, application panels, which are Views containers, load the .ilv files as well as the inline scripts. When you test the current buffer, Views Studio writes its contents together with the inline script to a temporary stream and creates a container that loads that stream.
Scripts can also be written in a separate external file, with the .js extension, using any text editor. When loading an .ilv file, the Views container checks whether there is a .js file with the same name in the current directory. If the container finds such a file, it loads it. You can explicitly load and evaluate an external script file by executing the Views Studio LoadScript command or by calling the Script function loadFile.
Published date: 05/24/2022
Last modified date: 02/24/2022