<< Click to Display Table of Contents >> Navigation: JavaScript > The JavaScript Editor |
Tutorial video about the JavaScript editor
Since the version 1.12.X of the OPUS Projektor, a new JavaScript editor is integrated and provides many new features.
JavaScript files can be created by right clicking on the JavaScripts node (1) insides the project tree and clicking New File... (2). Already existing scripts can also be used with Import File... (3). This functions copies the selected script file into the "terminal_files\scripts" folder of the corresponding project. Scripts from other projects can copied to the target project by using Paste (4)
A wizard for creating a new file will be appear. In the category JavaScript an empty JavaScript file can be created. The category JavaScript Samples includes different templates. These templates can help to understand the basics of the JavaScript programming language or show best practices for different use cases. On the next page the wizard shows some information about the location of the new file. The folder "terminal_files\scripts" shouldn't be changed. Only scripts in this folder will be displayed in the JavaScipts node inside the project tree. The absolute path of the file is shown in the Created File text field (1). The name of the JavaScript file can be changed in the File Name section. |
A script file can be edited by double clicking the corresponding file (1) insides the JavaScripts node. A new JavaScript editor tab (2) will be opened. In our example we have created an "Hello World" application with an template. The script file includes a function call "helloWorld()" and the definition of the function which prints out a String. To edit a script just write your source code in the content area (2). Syntax highlighting is supported. A summary of all functions will displayed in the Navigator View (3). To help writing a script with variable interactions, the Variable View can be used to get / set the value of all variables that exist in the current project. They are sorted by variable group. A variable can by dragged into the context area by DnD (Drag & Drop). Also objects can be dragged into the context area by DnD (Drag & Drop).
The current code line and
|
Already existing JavaScript files can be Copy / Paste into the same project or other projects. Also Rename and Delete of the files is supported and updates all references on events. Hint: Do not rename the script file over the file system when the file is referenced to object events, because then the references will be broken. |
We have included a plugin that allows JavaScripts with non-ANSI characters (UTF-8 format). By default, all script files will be opened and interpreted as UTF-8. When a script file is opened in the editor, the encoding format will be shown in the lower right corner of the program.
The encoding can also be changed by pressing this place. Normally there is no reason to use any other encoding than UTF-8.
Additionally it is possible to load and save a file in a certain format. There are entries in the menu File called Open in Encoding... and Save in Encoding... where a format can be chosen in which the selected file will be interpreted. |