Engee documentation

Script Editor

Script Editor interactive script icon — this is an Engee workspace tool designed to work with interactive scripts.

An interactive script (or simply script) is a file containing several sequentially executed commands.

To open Script Editor, click on the icon interactive script icon in the workspace:

img36a

Working with scripts

Creating a script

To create a script, click + in the script editor and select the desired format.:

img36c enimg36c 1 en

By default, Engee scripts have the format ngscript However , you can also work with the format jl and ipynb:

  • jl — script format in Julia language. The script editor supports refactoring and running scripts in this format.;

  • ipynb — a universal format for writing scripts in Python. The script editor supports all available functionality at the c level ngscript.

You can create a script using file browser file browser 7. To do this, right-click in the empty area of the file browser window to open the context menu, then select Create and Script:

script saving en

Opening an existing script

To open an existing script in a file browser window:

  • Double-click on the script with the left mouse button;

  • Right-click on the script and select from the context menu Open:

    img36b en

Script Editor Sections

You can create code or text cells in the script editor.

To create cells, move the mouse pointer to the top edge of the script editor window to display the cell selection button.:

script editor 1 en

  • + Code — creates a new section with a code (code cell). All the possibilities of writing code in this cell are available. the Engee programming language.

  • + Text — creates a new section with text (text cell). In this section, you can add and format any description, pictures, tables, links, etc.

New sections can be added anywhere in the workspace of the script editor (for example, at the beginning, end, or between two other sections).

The section with the code

Let’s create a section with the code and look at its interface.:

img52 en

  1. Run and advance — executes the code in this section.

  2. Run to end — executes all sections with the code below the selected section.

  3. Run before cell — executes all sections with the code above the selected section.

  4. Change position of output — selects a position for withdrawal. It has two options:

    1. 4.1. Code output on the right — outputs the result on the right for a specific section.

    2. 4.2. Hide code output — hides the selection of the result for a specific section.

  5. Mask — adds a mask for the selected code cell (for more information, see Masks of code cells).

  6. Move down — moves the section one down.

  7. Move up — moves the section one up.

  8. Copy — copies the section.

  9. Paste — inserts a section.

  10. Remove — deletes a section.

In the code cell, you can also:

  • Execute the selected section of the code (PCM on the selected line or hotkey Shift+F7) and Execute the selected:

    code sting completion en

  • Execute the current line with the cursor (Ctrl+Shift+F5 on Windows/Linux or Shift++F5 on macOS).

Section with text

To work with text cells, the WYSIWYG editor is used by default ("What you see is what you get"). For more information about text markup using the editor, see link.

Create a section with the text:

img44 en

Double-click on the section to open the input field, now you can enter the desired text in the cell that appears.

img44 1 en

A markup language is used to format the text. Markdown with the ability to extend functionality using HTML and LaTeX. Read more about the markup in a text cell in the articles Text markup in Engee and Working with Markdown in Engee.

Consider the interface of the text section:

text interface script en

  1. script editor text 1 — cancels the last action

  2. script editor text 2 — repeats the last canceled action

  3. script editor text 3 — applies bold font to selected text

  4. script editor text 4 — makes the highlighted text in italics

  5. script editor text 5 — applies a strikethrough effect to the text

  6. script editor text 6 — sets the header level (H1-H6)

  7. script editor text 7 — creates a bulleted or numbered list

  8. script editor text 8 — inserts a hyperlink

  9. script editor text 9 — forms the text as a quotation

  10. script editor text 10 — highlights text as a piece of code

  11. script editor text 11 — adds a task tracking checkbox

  12. script editor text 12 — highlights the selected fragment

  13. script editor text 13 — applies a monospaced font

  14. script editor text 14 — highlights the text background

  15. script editor text 15 — changes the color of the text

  16. script editor text 16 — adds a block of notes

  17. script editor text 17 — adds a hiding section

  18. script editor text 18 — inserts an image

  19. script editor text 19 — adds a table

  20. script editor text 20edit mode, select one of three modes:

    • script editor text 20 - WYSIWYG visual editor, immediately displays formatting without markup languages (used by default, recommended)

    • script editor text 21 — Markdown markup, manual editing of the source text

    • script editor text 22 — displaying the result (preview) without the possibility of editing

Similar to code sections in text cells, the following commands are used: move, copy, paste, and delete.

Hiding cells and contents

To hide cells in the Engee script editor, the text cell must be marked as a paragraph using Markdown, as well as have the appropriate level and location.:

  • the cell must contain a Markdown header from level 1 to level 6 (, # and so on).

  • There should be a cell with a lower-level header under the top-level header.

interactive par 01 en

In the script editor, you can hide:

  • code cells (have the lowest header level);

  • text cells without headings (also the lowest level);

  • text cells with lower-level headings.

    interactive scripts par 3 en

If a text cell with a first—level header has, for example, 10 code cells under it, this forms one section that will be hidden. When the 11th cell appears, a new paragraph with a heading of the first level or the same level as the first text cell, a new section begins.

The headings of the text cells from the first to the sixth level form Contents content button 1:

in scripts par en

In the content, you can:

  • Add paragraph content button 2 — adds a text cell with a title to a higher level. For example, if a nested paragraph is added to a first-level text cell (), then it will become a second-level cell (#). When the maximum nesting is reached (the last text cell has a sixth—level heading), the button is unavailable.

  • Play paragraph content button 3 — starts the execution of all cells with the code of the selected paragraph. If the paragraph does not contain code cells, the button is unavailable.

  • Remove paragraph content button 4 — deletes the selected paragraph. The headings and code cells nested in the section of the paragraph will not be deleted.

Starting/stopping scripts

To start or stop the script, click Run script or Stop execution. The buttons are located on the script launcher.:

img53 en

To start the section with the code, click on Execute. The result will be displayed below under the section:

img 49 1 en

You can collapse the code execution output into a more compact form if it takes up too much space. To do this, use the button Unexpand output colapse button:

in long hide 1 en

To return the output to its previous state, use the button Expand output colapse button 2.

To clear the results of code sections in the script, click on the icon Clear output on the script launcher.

img62 en

Saving the script

To save the script, click the icon Save on the script launcher.

img5a en

If you plan to open scripts written in Engee on third-party systems (for example, Jupyter), it is recommended to change the extension of the saved script using the Engee file browser.:

img5 1 en

Additional settings

Script Editor It provides a number of additional settings that help simplify working with code and text. They will be useful when working with large files, parallel script editing, or text files.

To access these settings, click on the colon icon in the upper-right corner of the script editor.:

script editor other settings 1 en

Auto save

Function Auto save allows you to save changes to interactive scripts automatically, preventing data loss.:

scripts autosaving 1 en

There are three auto-save options available:

  1. afterDelay — The script is automatically saved after a certain delay time. When this option is selected, the default delay is 1000 ms.

  2. onFocusChange — the script is automatically saved after the editor loses focus. This means that when switching to another Engee window, the changes in the script editor will be saved.;

  3. onWindowChange — The script is automatically saved when switching from the browser tab where Engee is open to another tab. This means that when you change the browser tab from Engee to any other, the changes in the script editor will be saved.

Word wrap in text files

Function Word wrap in text files It is displayed in the advanced settings menu in the following cases:

script editor other settings 3 en

  • If a text file is open;

  • If the script editor is empty (no files are open).

In other cases, the function is hidden.

Function Word wrap in text files enables word wrapping in text files (not to be confused with text cells). This means that strings in text files (in formats such as .txt or .json) are automatically transferred to a new line without horizontal scrolling.:

The function is enabled

The function is disabled

script editor other settings 5 en

script editor other settings 4 en

Left-right split

script editor other settings 6 en

Function Left-right split enables the two-column mode, in which the editor window is divided into two parts. This allows you to open and edit two interactive scripts at the same time.:

script editor other settings 2 en

The width of the columns can be easily adjusted: hover the cursor over the border between the columns, hold down the left mouse button and drag the divider in the desired direction.:

script editor other settings x en

Masking code cells

Script Editor supports the ability to turn variables in code cells into convenient interactive elements — drop-down lists, input fields, sliders, and other control components. To do this, the code cell mask mechanism is used to improve the visual representation of scripts, hide technical implementation details, and simplify data entry.

To apply a mask, use the tool Mask masks script pool 1, which appears when you hover the cursor over the code cell:

masks script pool 2 en

For more information about the types of masks, settings, and manual operation, see Masks of code cells.

Breakpoints

The Engee editor supports adding breakpoints to code cells. This is convenient when debugging scripts — code execution is paused at the desired line, which allows you to step-by-step examine the behavior of the program and find errors.

To set a breakpoint, hover over the left border of the desired line and left-click.:

adding breakpoints

To set up conditions, delete or temporarily disable a stop point, you can use the context menu (red dot PCM).

Engee offers various types of breakpoints: basic, conditional, delayed execution, and others. Trigger conditions can be set using expressions, the number of iterations, or dependence on other points.

For more information about working with breakpoints, see Script editor breakpoints.

Software management methods

Using public methods (for more information, see Public methods of program management) you can manage Engee scripts without using the script editor interface. These commands are designed to work with script editor files and are invoked via engee.script. Let’s look at each of these methods.:

@include — includes (embeds) script code instead of calling a macro.

For example, we have a script named new.ngscript, in which the code is written — a = 1. Let’s create another script, new_1.ngscript, in which we will access the first one along the absolute path through @include:

engee.script.@include("/user/new.ngscript")

The result of executing the code of the first script a = 1 it will be included in the second script and will be equal to 1.

Team @include and the embedded code should not be in the same script. Otherwise, a cyclic dependency error will occur when @include I have to call myself.
edit — opens the script for editing.

Opens the script for editing using the specified path. If there is no script file, it is created automatically.

engee.script.edit("/user/new.ngscript")
If the extension is specified otherwise from .ngscript, then outputs an error ErrorException("path should end with.ngscriptextension").
extract_code — extracts the code in the specified path.

Extracts the code from the script using the specified path. For example, for the new.ngscript script with the code a = 1:

engee.script.extract_code("/user/new.ngscript")

Conclusion:

:($(Expr(:toplevel, :(#= none:1 =#), :(a = 1))))

For more information about other public methods used in scripts, see the article Software control of modelling.