1C:Enterprise script





1C:Enterprise script is an important part of 1C:Enterprise technological platform because it provides developers with tools for describing custom applied solution algorithms.

1C:Enterprise script has much in common with other programming languages, such as Pascal, JavaScript, and Basic, which simplifies the learning curve. But it is not a replica of any of these languages.

The major features of 1C:Enterprise script are:

  • preliminary compilation: modules that contain 1C:Enterprise script are converted into internal code before their execution;
  • compiled modules are cached in memory;
  • weak typing: a variable type is defined by the stored value and can change over time;
  • no programming description of configuration objects: developers can use the objects that are built into the platform or applied solution objects created in a visual editor.

Event-driven language

The methodology of applied solution creation defines 1C:Enterprise script purpose. Applied solutions based on 1C:Enterprise are never written in pure code. Developers create applied solutions mostly in visual editors. This includes creation of configuration objects and specifying their properties, presentation forms, interrelations, and so on. 1C:Enterprise script is only required for describing nonstandard behavior of applied solution objects and custom data processing algorithms.

Therefore, modules that contain 1C:Enterprise script are only used in certain situations that might occur at run time. These situations are called events. Events can be related to the functionality of applied solution  objects or to the applied solution itself.

For example, the functionality of the applied solution object Catalog includes a set of events. One of them is BeforeWrite.

This event occurs before the catalog item data is written to the database. A developer can use 1C:Enterprise script to write an algorithm that checks whether the data entered by user is valid. By adding the algorithm to the appropriate module, the developer ensures that every time a user attempts to save a catalog item the platform will run the algorithm for checking whether the user filled all mandatory catalog attributes.

In other words, 1C:Enterprise script is a script language for describing business logic, and 1C:Enterprise script module calls are event-driven. Modules are executed when specific events occur in the applied solution.

Universal value collections

1C:Enterprise script includes a large variety of objects. Of course, applied objects form the most essential object group because they are used for describing business logic algorithms.

However, objects that store temporary user session data are also important. They usually serve for collecting, grouping, analyzing, and processing data.

Let us briefly review their functionalities.

Array

A numbered collection of values that can have any type. You can access an array element by its index. An array element can be an array itself, which allows building multidimensional arrays.

Structure

A named collection that consists of key-value pairs. Keys always have string type and values can have any type. You can access a structure element by its key (i.e. by name). Structures are intended for storing a small number of values where each value has a unique name.

Map

A collection of key-value pairs, similar to a structure, with the following difference: keys can have almost any type.

List of values

A list of values is intended mostly for interface tasks. Lists of values are used for building and managing dynamic value sets (which includes adding, editing, deleting, and sorting elements). They can store values of any type. Moreover, a single list can store values of different types.

For example, you can use a list of values for selecting a specific document from the list of documents generated using a complex algorithm.

Value table

A value table is used for building and managing dynamic value sets. It can store values of any type. A single table can store values of different types.

For example, you can use a value table for creating a presentation for a list of catalog items in a form, provided that the list of catalog items is generated using a complex algorithm.

Value tree

A value tree is a dynamically generated set of values of any type, similar to a value table. Unlike value table rows, rows of a value tree can form hierarchical structures. Each tree row can have a set of subordinate rows, which, in turn, can also have subordinate rows, and so on. Searching for values, sorting, and getting totals can be performed either within the current hierarchy level or within the current level and all subordinate levels.

COMSafeArray

An object wrapper over multidimensional SAFEARRAY from COM. COMSafeArray is used for creating and managing SAFEARRAY instances for exchanging data between COM objects.

FixedArray

An array that cannot be changed. It is filled by the platform during the initialization of objects of this type. Alternatively, a developer can fill it using the array constructor.

Text and module editor

Developers can use the text and module editor for writing or editing 1C:Enterprise script. The editor provides handy tools for writing, editing, and performing syntax checks.

See also:


Comments
0
Add comment