1C programming language (1C:Enterprise script) is the programming language embedded in the 1C:Enterprise platform. It's important part of 1C:Enterprise technological platform because it provides developers with tools for describing custom applied solution algorithms.
1C programming language 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 programming language are:
- preliminary compilation: modules that contain 1C programming language 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 programming language purpose. Applied solutions based on 1C:Enterprise are never written in pure code. Developers create applied solutions mostly in visual editors. This includes the creation of configuration objects and specifying their properties, presentation forms, interrelations, and so on. 1C programming language is only required for describing nonstandard behavior of applied solution objects and custom data processing algorithms.
Therefore, modules that contain 1C programming language 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 programming language to write an algorithm that checks whether the data entered by a 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 programming language is a script language for describing business logic, and 1C programming language module calls are event-driven. Modules are executed when specific events occur in the applied solution.
Universal value collections
1C programming language 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 tableA 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 programming language. The editor provides handy tools for writing, editing, and performing syntax checks.
Next page: 1C:Subsystems library
See also: