1C:Enterprise script editor

The 1C:Enterprise script editor available in EDT is different from the 1C:Enterprise script editor available in Designer. The key difference between the editors is the method of defining variable types. To define variable types, EDT analyzes the following parts of the configuration script:

  • Calls of developer-defined methods (at all nesting levels) and 1C:Enterprise script methods
  • Event handler execution context
  • Comments to 1C:Enterprise script methods

This significantly expands the functionality of the context help that is available when you type the module script. First, the context help better determines variable types. Second, it provides the following options that speed up typing:

  • When you type a word, the top part of the context help list displays items that start with that word. They are followed by the items that contain the word. For example, if you need a list of objects related to XDTO, type XDTO and select the object that you need from the list.
  • You can get a shorter list by typing several word parts. For example, if you type GetObForm in a form module, the context help list offers GetObjectAndFormAttributeConformity() and GetObjectAndFormConformity() methods.
  • You can type even a shorter fragment that contains only the first letters of a compound 1C:Enterprise script word. For example, if you need to type New FileDialog, it is enough to type New FD and then the context help list will display FileDialog at the top.
  • Remember that the context help only displays properties, objects, and methods that are available in the current context.

To generate a comment to a method, right-click a method, point to Source, and click Generate Method Comment, or use the special context help mode. To use the latter method, move the insertion point to the blank line above the procedure or function name, press Ctrl + Spacebar, and then press /. The context help prompts you to enter a comment. When you press Enter, EDT generates a comment template with a list of method parameters.

In addition to names and types, the context help facilitates the creation of event handlers. This feature is available on the second page of the context help. To open the second page, press Ctrl + Spacebar again. Thus, the context help consists of two pages, the first page displaying the list of available methods and variables, and the second one displaying the list of event handlers available in a specific module part. You can switch between the pages by pressing Ctrl + Spacebar. There is another way to create an event handler: right-click in the module text and click Add Event Handler. This opens the dialog box where you can filter event handlers by name and view their descriptions.

EDT supports templates that are similar to Designer templates. You can add 1C:Enterprise script structures using the templates provided by the context help. Templates can have parameters. To switch between template parameters, press Tab or Shift + Tab. To finish editing the parameters, press Enter.

One can easily make a mistake when typing method parameters. To avoid this, the 1C:Enterprise script editor displays all of the variables that you can use as parameters in the context help window.

If your method uses a constant value multiple times, you can use the refactoring feature to optimize this. The refactoring moves the calculation of the constant (invariant) value to a new line inside the method (a variable assignment) and then replaces all occurrences of the invariant expression with this variable. To use this tool, right-click an expression that you want to optimize, point to Refactoring, and click Extract Local Variable.

EDT offers other refactoring options as well. To move a script fragment to a new method, select the fragment, right-click it, point to Refactoring, and click Extract Method. To rename a variable or a method, right-click it, point to Refactoring, and click Rename.

EDT validates configuration modules as you type, it marks validation errors directly in the editor and also displays the list of errors in the Configuration Problems view. Double-clicking an error in this view moves you to the module line where the error is detected. In some cases you can use the Quick fix tool to fix an error. So far it can do the following:

  • Create a variable that is used in the script but not declared.
  • Create a procedure or function that is called in the script but not declared.

You can mark a script fragment as a region (enclose it in #Region ... #EndRegion preprocessing instructions). To add a region, select a script fragment (a part of a method or several methods), right-click it, point to #Surround With and click #Region.

You can use the following debug tools:

  • Open call hierarchy. To view method call hierarchy, right-click a method and click Open Call Hierarchy. The Call Hierarchy view displays all of the method call stacks. You have the option to view and analyze both ascending and descending method call stacks.

A descending stack is a stack that begins with the call of this method. It includes all of the methods called from this method, at all nesting levels. An ascending call stack includes all methods that call this method, with all occurrences of the method. The last method in an ascending stack (which is actually the first one) is the interactive event handler that initiates the call stack that includes the method call.

You can right-click any method in a call chain (in the 1C:Enterprise script editor) and then click Focus On Selection. This replaces the method being analyzed with the selected one. You can analyze it just like you analyzed the previous method.

  • Find references to a method. To view method call hierarchy, right-click a method and click Find References. This opens the Search view with a list of modules that contain the method calls. The list is displayed as a two-level tree. The first level contains modules (displayed as full module paths) and configuration objects, and the second one contains the method calls. For each call, the list displays the name of the method that contains the call. If a method contains multiple calls, the list includes several lines with that method name. If the method being analyzed is a handler, the first-level item is the form item or object where the handler belongs. Double-clicking a list item opens the module editor with the method call highlighted.

EDT includes the Outline view that simplifies navigation through the module. It displays all of the module methods, grouped by region and module-level preprocessor instructions. Handler names are highlighted with color. A green or red square next to a procedure or function name shows whether it is exported (green) or not (red). You can reorder the module parts by dragging them in the Outline view. For example, you can use this feature to regroup methods during the refactoring. To copy a method, drag it while holding down Ctrl. Then you can edit the method copy. The Outline view displays module-level regions. Clicking a method in the Outline view locates this method in the editor window. Pressing Enter on a method or double-clicking it activates the module window with the method declaration line selected.

EDT also includes the Quick Outline tool that is similar to the Outline view. It is displayed as a pop-up in the 1C:Enterprise script editor. You can use the Quick Outline window to search for methods (wildcards ? and * are allowed). EDT keeps the last used Quick Outline panel size and position.

To mark occurrences of a variable in the current procedure or function, use the Toggle Mark Occurrences command. While this option is active, 1C:Enterprise script editor highlights the occurrences of the selected variable.

Next page: Role editor

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.