h2. Script Editor

Ribbon: Manage – Applications > Script Editor
Menu: Tools – Scripts > Script Editor…
Command line: SCRIPTED
The built-in script editor allows you to create, edit and run batch files of various formats: ActiveX (.JS, .VBS), LISP (.LSP), DCL, SCR.

Buttons

New File. Select the type of script in the drop-down menu.
Open Script
Save Script.
Save As.
Undo.
Redo.
Find Text. Opens the collapsed Search and Replace bar.
Replace Text. Opens the expanded Search and Replace bar.
Run Script.
Options.
Help.

Search-Replace bar

Fold/Unfold the Replace field.
The search pattern field.
Find Next.
Close bar.
The replacement pattern field.
Replace Next.
Replace All.
Match Case.
Use Regular Expressions.
Match Whole Word.

Shortcuts

Select All Ctrl+A
Copy Ctrl+C, Ctrl+Ins
Insert Ctrl+V, Shift+Ins
Cut Ctrl+X, Shift+Del
Undo Ctrl+Z, Alt+BackSpace
Redo Ctrl+Y
Go to String Ctrl+G
Find Ctrl+F
Find Next F3
Find Selected Ctrl+F3
Replace Ctrl+H
Open Ctrl+O
Save Ctrl+S
Save As Ctrl+Alt+S
Properties Ctrl+P
Run Ctrl+R
Find the Matching Pair Bracket Ctrl+{

Options

The button opens the script editor Options dialog, where you can configure font settings for each category of a specific programming language.


The Font tab of the Options dialog allows you to configure font settings for each category of a specific programming language.

The Options tab allows you to configure general options for displaying the code in the edit window.

Options:

Tab size Tab Size in spaces: the number of spaces to be inserted into a line when the Tab button is pressed on the keyboard.
Autoident Enables/disables automatic indentation of a new code line identically to the indentation of the previous line.
Brace highlight Highlighting the opening and corresponding to it closing brackets when the cursor is on one of them.
Restore last script Automatic loading of the latest script when opening the editor.
Folding Enables/disables the text-block folding node. Text blocks are detected automatically.
Style Folding Node Style: Arrows, Plus/Minus, Circles, Squares.
White space marker size The size of the white space marker in pixels. To enable the display of the space character, press CTRL+W on the keyboard.
Preserve encoding Preserves the original encoding of the script file.
By default, the script editor uses UTF-8 encoding. All new scripts created in the script editor will have this encoding.
When opening a script file in the script editor, the encoding is determined automatically. If the Preserve encoding box is checked, then the script will be saved after editing in the same encoding it was in before opening in the script editor. If the checkbox is cleared, then the script will be saved in ANSI encoding (the current user encoding) after editing.

Find and Replace in Scripts
The script editor has several tools to quickly find the right part of the code:
· Find and replace bar;
· Bookmarks;
· Panel for jumping to a line by its number.

Find and Replace Bar

To search for text in scripts, you can open the search bar in one of the following ways:
· By clicking the Find text button in the script editor;
· By the CTRL+F keys combination on the keyboard. In this case, the cursor must be in the text field of the script editor.

The search bar will appear at the bottom of the script editor below the script text edit field:

Find/replace mode switch button. When you click on the button, additional fields are opened for setting up the replacement of the found text. Clicking again hides additional fields.
Search pattern input field. You can enter single text characters, character sets, and regular expressions in the field. When you click on the button located in the right part of the field, this opens a list of the latest requests entered.

Find next. Pressing the button moves the cursor to the next match of the script text with those entered in the search pattern input field.
Use regular expressions. Regular expressions will be used to search for text in the script.
Match case. The search will take into account the case of the characters entered in the pattern field.
Match whole word. The search results will only display exact matches with the text entered in the search pattern field.
Close the bar.

To automatically replace text in a script, open the replacement bar in one of the following ways: · By clicking the Replace text button in the script editor; · By the find/replace mode switching button on the search bar; · By the CTRL+H key combination on the keyboard.

Elements of replacement bar to set the text replacement:

Replacement pattern input field. The field is intended for the text with which you want to replace the found text according to the pattern from the text search field. Clicking on the button on the right side of the field opens a list of the most recently entered replacement patterns.
Replace. Clicking the button replaces the found text in the current fragment of the text file.
Replace all. Clicking the button replaces all matches found in the text file that match the text search pattern with the text specified in the text replacement pattern.

Regular Expressions

A regular expression is a text search pattern that uses special characters to search for multiple spellings of an expression in a single search query.

To search for text in scripts using regular expressions, click the Regular expressions button on the search bar. Repeated clicking the button disables regular expression search.

The following special regular expression characters are allowed:

. Replaces any character. For example, the expression Layout.. will find all entries of the format Layout01,Layout02, Layoutaa, etc. in the script.
\ Escapes the character following it from being read as a special character. For example, the expression Layout\… will find in the script all entries of the format Layout.01, Layout.02, Layout.aa, etc., that is, the dot character after Layout will not be recognized as a special replacement for any character.
[ ] Inside square brackets, a set of options is specified, either as single characters or as ranges. It is not necessary to separate options with a space. When specifying a range, the start and end values are separated by a – sign.
For example, the expression [1-9] will find in the script all the numbers from 1 to 9, the expression [a-z] will find in the script all the characters from a to z, and the expression [ab1] will find in the script individual characters either a, or b, or a number 1.

Applied to a character in the text and says that this character can either be absent or repeated from one to several times.
For example, the expression Layout0*. will find entries of the form both Layout1 and Layout01, Layout001, etc.
+ Applied to a character in the text and says that this character can be repeated from one to several times.
For example, the expression Layout0+. will find entries of the format Layout01, Layout001, etc.
? Applied to a character in the text and says that this character can either be absent or repeated only once.
For example, the expression Layout0?. will find in the text records of the forms Layout1, Layout01.
^ Negative symbol. Applies to the character to be excluded from the search results.
For example, the expression Layout.[^a-z] will find all entries in the script that contain the word Layout, followed by any character, and then any character other than the English letters from a to z.
$ End of line character. Applied at the end of the regular expression so that nothing extra is included in the search results.
For example, the expression Layout.[^a-z] will show Layout001 as a search result that matches the conditions, despite the fact that there is an extra character – 1 at the end. The expression Layout.[^a-z]$ will not include this entry in the search results.

More information about regular expression syntax can be found here.
Bookmarks

To move quickly between lines, you can use bookmarks. Bookmarks are displayed as red flags on the left vertical bar of the script editor window next to the corresponding lines of code:

You can bookmark aline in two ways:
· by clicking the left mouse button on the bookmarks bar opposite the required line;

· by placing the cursor on the required line and pressing the Ctrl+F2 key combination on the keyboard.

You can delete a bookmark in the same ways:
· by clicking the left mouse button on the bookmark flag;

· by placing the cursor on the line with a bookmark and pressing the Ctrl+F2 key combination on the keyboard.

You can delete all bookmarks at once by pressing CTRL+L.

To quickly jump between lines marked with bookmarks:
· to go to the next tab, press F2 on the keyboard

· to go to the previous bookmark, press SHIFT+F2.

Move to a Line by Number
To move to a script line by its number, open the corresponding bar in the script editor by pressing CTRL+G on the keyboard.
The bar will appear at the bottom of the script editor

The bar elements:

The field shows which line the cursor is on.

A field for entering the number of the line to move to.

The total number of lines in the script.

Button to move to the desired line.

Close the bar.

Shortcuts

Many actions in the Script Editor are available through keyboard shortcuts. However, they work only during script editing, that is, when the cursor is in the script editing text field.

Select All Ctrl+A
Copy Ctrl+C, Ctrl+Ins
Insert Ctrl+V, Shift+Ins
Cut Ctrl+X, Shift+Del
Undo Ctrl+Z, Alt+BackSpace
Redo Ctrl+Y
Go to String Ctrl+G
Find Ctrl+F
Find Next F3
Find Selected Ctrl+F3
Replace Ctrl+H
Open Ctrl+O
Save Ctrl+S
Save As Ctrl+Alt+S
Properties Ctrl+P
Run Ctrl+R
Find the Matching Pair Bracket Ctrl+{
Display/hide space characters Ctrl+W
Set/unset bookmark in the line Ctrl+F2
Move to the next bookmark F2
Move to the previous bookmark SHIFT+F2
Delete all bookmarks CTRL+L

In the same dialog, you can also configure general options for displaying the code in the edit window.

Info: NanoCAD is a user friendly, low cost, and yet powerful, CAD application for Windows, that allows an outstanding user experience by providing top-level performance, full capability, a classic interface and native.dwg format support. nanoCAD has been built to deliver design and project documentation for all industries. nanoCAD includes a full suite of basic and advanced CAD tools for 2D/3D drafting and creating industry-standard DWG-compatible CAD files. Our program provides groundbreaking, collaborative and customizable features to raise your efficiency, and includes a few API’s, allowing anything from routine task automation to complex CAD app development. You may download nanoCad for free, using the links below, and buy later, if you like it.

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment