This article discusses setting up and using the VSCode external programming environment to call programs in the TRIK Studio 2D model.
This will allow experienced TRIK Studio users to use all the features of professional text editors and their plugins: static analyzers, auto formatters, color themes.
It also describes how to automatically run the program on several fields, which can be useful for participants in competitions with automated verification systems.
It is assumed that the user is writing a program in an external editor and would like to run this program on one or more fields. Fields can be presented both in .xml
format (for more details, see the article "2D model tuning"), and in .qrs
format.
Download run_2d_model.cmd for Windows or run_2d_model.sh for Linux and place it in the folder where TRIK Studio is installed.
Place the fields on which you want to test the program in a separate folder. If the fields are in .xml
format, create an empty default.qrs
project in this folder.
The manual was tested on the January 2020 release (version 1.42). You can download VSCode from the official website.
1. Create a folder where the source code file will be placed.
2. Open this folder in VSCode with File → Open Folder
.
3. ChooseTerminal → Configure Tasks
.
4. If there were no tasks before, then selectCreate tasks.json file from template → Others
in the drop-down menu . The file tasks.json
will be opened. If tasks were created earlier, it will open right after point 3.
5. Delete everything from this file and paste this code, where <path to field dir>
is the full path to the folder containing fields:
6. Depending on your operating system, edit the filetasks.json
:
For Linux, in the line corresponding to the "command"
field, specify the path to the edited run_2d_model.sh
and specify your source code file as the third argument. This file should be located in the folder that we opened with VSCode. Example: "command": "/home/admin/TRIKStudio/run_2d_model.sh /home/admin/fields/ script.js"
For Windows, in the line corresponding to the
"windows": { "command"
field, specify the path to the edited run_2d_model.sh
and specify your source code file as the third argument. This file should be located in the folder that we opened with VSCode. Example:
"command": "D:\TRIKStudio\run_2d_model.cmd D:\Users\Admin\fields script.js"
7. Save the filetasks.json
.
8. Now select Run TRIK 2D model
in the dropdown menu Terminal → Run Task
or press the corresponding keyboard shortcut (Ctrl+Shift+B) to run your code.
For the proposal to add this functionality, the TRIK project team thanks Alexander Zhuravlev, the participant of the NTI IRS Olympiad 2018-2020.