How to set up smartphones and PCs. Informational portal
  • home
  • Advice
  • 1c enterprise built-in programming language. Loops using a boolean expression

1c enterprise built-in programming language. Loops using a boolean expression

Even if you have previously studied other programming languages, for example, C ++, PHP, Java, it is worth remembering that 1C, although in many respects, still has many fundamental differences.

The most important thing in 1C is that you don't need to invent your own types of objects. All of them are already in the configuration.

Install the 1C technological platform on your computer, and open a new or existing base in the configurator. For starters, you can use it absolutely for teaching programming.

On the left side of the window, you will see a tree of configuration objects. These include documents, directories, registers, business processes, and more.

The data is also stored in the DBMS, but the developer usually does not work with them directly. With the help of the technological platform, the programmer already refers to the objects of the configuration or infobase.

In 1C, as in many other programming languages, queries are very often used. similar to the T-SQL language. Requests can be written in both English and Russian, among other things, like the rest of the code.

Everything seems to be simple, but knowledge of a programming language is often not enough to work "in the field". The fact is that in most organizations using 1C, standard configurations are installed, and you need to know them.

In the work plan for 1C programmers, there are two main branches: franchisees or work "for themselves" and work as a full-time programmer of the IT department of any organization. This choice depends only on your preferences.

When working for a franchisee, freelancing or running your own business, the payment will be piecework. There can be a lot of work and you need to give all your best. There is no cap on wages, and you can make an impressive amount of money.

If you decide to work freelance or open your own business, you will not need to “share” your earnings with anyone (except for the state and the freelance platform, of course). But in this case, it will be necessary to look for clients on your own.

If you nevertheless decide to get a job in the organization as a full-time programmer, then you will not depend much on the amount of work performed. In this case, there is some stability, but the salary bar is also limited.

Of course, these two methods can be combined, working as a full-time programmer during the day and freelancing in the evenings.

What is good about 1C programmers is that you may not have a technical education (for example, you are an economist, accountant, etc.). To confirm your knowledge in front of clients or an employer, you can provide your 1C certificates.

Certificates are of various types, both by platform (for programmers) and by standard solutions. You can get them at 1C by passing an exam in the form of a test or practical assignment.

Books on 1C

It is best to study 1C from books that were published by 1C. From the source, so to speak. Some of them come with the delivery of typical configurations. You can also buy individual books.

The book "1C: Programming for Beginners" is intended for people far from programming, but who want to learn how to create their own solutions on 1C 8.3 from scratch.

"Hello, 1C" shows the simplest, basic possibilities of developing applied solutions in the 1C: Enterprise 8 system.

101 Tips describes different ways to accomplish the same tasks.

A practical guide for the developer 1C Enterprise 8.3 is a very detailed guide that describes development techniques with simple and understandable examples. This book is one of the best for learning 1C programming.

This tutorial describes a query language from scratch for those who are not even familiar with SQL.

If you write in SI
Be at least three times lamer
They say about this:
"He's a cool programmer!"
(Fidoshnye songs - "What is Suxxx and What is Rulezzz")

Foreword

The reason for writing this article was the negative attitude of the professional community towards this platform and programmers.

As a programmer who chose 1C, I think this opinion is unfounded. The 1C platform is far from ideal, but, in my opinion, it is the best, and most importantly, a domestic product!

And even more so - it is inadequate to judge the abilities of a programmer by the language in which he writes.

In this article I will describe the benefits that I have found for myself in the program. The article will turn out to be almost an advertisement, so immediately disclaimer:

  • I have no direct relation to 1C;
  • This article is not customized, and is written solely on a voluntary basis;
  • In some cases, a personal opinion is expressed, which may not coincide ...;
  • The entire article, with the exception of the prologue, is the author's, any coincidences are an accident;
  • We will talk about the 1C Enterprise 8.2 platform (currently version 8.3 is relevant, but I have not studied it yet - there is a lot of work on 1C 8.2). However, most of what has been said applies to both the 8.3 platform and earlier versions, and some of it applies to version 7.7 as well.
So let's get started.

What are we talking about?

Platform 1C Enterprise 8 is:
  • Works in two versions - file and server (three-link) - each has its own advantages and disadvantages;
  • An independent accounting system that is easy to install and configure;
  • Powerful ecosystem for programmers with all the necessary objects and tools;
  • Nice ergonomic interface;
  • A relatively inexpensive business solution;
  • Franchisee network, initial training;
  • A powerful base of developments and knowledge accumulated over the years;
  • At times a problematic platform for system administrators;
  • Not the fastest execution of algorithms (although not the slowest) is a tribute to the information content (in case of errors, the line number and its content are indicated);
  • The programming language has no classes (inheritance, encapsulation, polymorphism), no anonymous functions and other modern features. But for solving most of the problems, this is not even necessary!
For the organization of accounting - one platform is not enough. The platform is a kind of "engine", an intermediate link between the program and the database. The programs for this "engine" are called configurations. The configuration describes the structure of the database in the form of objects, the texts of procedures stored in separate modules (there are many modules, they are both in each object and in the system as a whole, and there are also common modules). The platform provides a level of abstraction in which direct access to the database is not required, and also allows you to abstract from the operating system and the type of database.

File and server databases

The platform consists of several parts and can work in a file or server version.

In the file version, the entire database is contained in one file (with the "1cd" extension) - the platform is installed on each computer and directly reads / writes to the database.

The advantages of the file option are low cost and ease of deployment.

Cons - the structure of the "1cd" file is closed, there is no single system interacting with the database. As a result, it is difficult to use with a large number of users (tried for 20+ users - you can work). In addition, dynamic updates fail when the database size is approximately 15 GB (or more). Resolving such failures is a difficult task, and the database repair utility does not always effectively repair, and sometimes even cripples the database.

There is a solution - this is, first of all, setting up a daily database backup. In addition, craftsmen not only publish the 1cd file format, but have also developed utilities for working with such files and a number of methods to solve similar problems.

In the server version, the platform for storing the database uses a SQL server (usually this is MS SQL, but starting from 8.2.14 - you can use some others, for example, Firebird PostgreSQL, IBM DB2, Oracle Database), and the platform itself uses a three-tier architecture:

Some of the code is executed on the client, some on the server. In this case, only the server interacts with the database. At the same time, starting from version 8.2, in addition to the standard operating mode, which was called the "thick client" mode, there were two new operating modes - "thin client" and "web client"; also appeared "managed forms", the appearance of which is built in the form of an abstract tree of elements. Programming for managed forms and a three-tier architecture is more difficult, but it allows you to transfer almost all the load to the server (i.e. you can buy one powerful server and a hundred of the cheapest office computers).

Platform advantages: "three-link" - load distribution, database openness (officially, 1C company refuses responsibility for any data corruption if changes were made to the SQL database other than by means of their platform or server, but this stops few people), no restrictions.

Cons - the price: you will have to buy separately client licenses for each client computer, separately - one license for the 1C server, a separate license for the SQL server, if you do not use the free one. Also, sometimes there are difficulties in the operation of the database. They are solved much faster due to the availability of data and the presence of external tools for working with the database. In addition, in this case, you should make a backup of the database.

A common advantage is the versatility of the configuration code: with some exceptions, the configuration developed for the file database will work on the server database, and vice versa. An example of an exception is the transfer of a mutable value to the server or from the server to the client (in the file version this will not cause exceptions, but in the client-server version it is prohibited).

Another plus: the platform is installed very simply, something like this: "Next-Next-Next-Ok", no fine tuning and installation of any components is required.

For the server version, there are a few more settings, but everything is done in the installation dialog and does not require prescribing anything in separate files. The installation of the SQL server can be somewhat difficult, since in this case, there are much more settings (and to fine-tune it, you need to study additional instructions). But this does not apply to the problems of the 1C platform. Moreover, if you install, for example, an MS SQL server with all the default settings, then 1C will be able to work with it.

It's more than accounting

When it comes to the 1C platform, it is presented, first of all, as a program for accounting. Indeed, this is the most popular area of ​​using the 1C platform. But 1C does not live by accounting alone!
Those who are familiar with the platform say that it is an accounting system (accounting automation). This is closer to the truth - there are many configurations, both from 1C and from third-party developers. Some are only indirectly related to accounting, some are not related at all.

In general, it is more correct to represent the 1C platform as a shell for object modeling of the database, interface and programming in the 1C language. The only limitation is that for each configuration its own database is created, and only one (however, it is possible to additionally connect external data sources as part of the configuration, i.e. other databases).

Ecosystem for programmers

Let's now consider the 1C language and the platform from the developer's point of view:
Database Object Model. First, we do not work directly with databases. It's not needed. For our convenience, all data is presented in the form of interconnected objects (directories, documents, information registers, accumulation registers, ...), and the platform automatically pulls this data out of the database.
For example, provided that the variable "Nomenclature Element" contains a link to the item of the Nomenclature catalog, the Nomenclature catalog has the PrimarySupplier variable, of the Catalog.Contractors type, and the Contractors catalog has the FullName property, then the code:

ItemNomenclature.PrimarySupplier.Full
... will lead to the fact that the 1C platform, using internal mechanisms, finds an entry in the table corresponding to the "Contractors" directory by the identifier from the "Main Supplier" field of the item item and returns the value of the field corresponding to the "FullName" field in the object model of the "Contractors" directory.

There can be many such dereferences - the system will cope. The only caveat is that the system does not know how to optimize dereferencing, so you should strive to take them out of all possible loops.

In addition to objects describing data, there are a huge number of system objects - for a wide variety of functions. I will highlight some of them:

Value stores
Array- an object that stores a set of data, in contrast to the classical representation of arrays. It can be data of various types (number, string, reference, other object). It has minimal functionality and is mainly used as a temporary container for transferring values ​​between other storages.

List of Values- an object, mainly for working with the user interface. In addition to data, for each element it can also contain a view, a flag sign and a picture (pictogram). It also has the methods "SelectElement ()" and "MarkElements ()" - when called, the interface dialog is shown to the user (which is convenient - there is no need to create this dialog in the configuration).

Structure and Conformity- storages of paired values ​​"Key and value". In the "Key" structure, this is a string that obeys the rules for naming variables in 1C (no spaces, start not with a digit, consists only of letters, numbers and an underscore). According to - "Key" is any value. The fastest searching for objects is matching (faster than in an array and an indexed table of values).

Table of Values- a very convenient, and rather fast, object for storing and processing data. Columns in the value table can be added and removed, regardless of the number of entries. In this case, the data in the rows is not lost (or only data from the cells corresponding to the deleted columns is deleted). Also, it has a "SelectRow ()" method that invokes the row selection dialog. There are indices.

Value Tree- an object representing hierarchical data. Contains columns, the set of columns is the same for all records at all levels. Removing / adding columns in a value tree is just as easy as it is in a value table. Also, it has a "SelectRow ()" method.

Interface objects and objects for working with various data TextDocument, SpreadsheetDocument, Web Browser, FileReader, FileWriter, ZIPFile Reading, ZIPFileWrite, XMLReader, XMLWriter, HTTPRequest and many more objects, all of which have built-in help for everything. The purpose of the listed objects can be seen from their names and all this is immediately available in the platform.

Separately, it should be noted that there is an object "Metadata" - with which you can study the data structure in the programming language, as well as for each link or object for a reference book, document, chart of accounts, etc. there is a method "Metadata ()" - providing a description of this reference book / document / chart of accounts / etc. in the database (what details, tabular sections are available, the length of the code / number, etc.). It is often very convenient.

And one more separate mention should be made of the objects: "Query", "QueryConstructor", "QueryBuilder", "Report Builder", "DataComposition Scheme". This family implements a set of objects for working with the powerful 1C query language.

Query language. Queries in 1C are used only to obtain a sample of data with convenient selection, sorting, groupings. As a first approximation, this is the “SELECT” statement from SQL translated into Russian, however, in the 1C query language there is also functionality that is absent in SQL, namely:

  • Working with 1C configuration objects instead of SQL tables;
  • Working with links instead of SQL identifier fields;
  • Dereferencing support, similar to how it is done in code;
  • Selection by entry into the group (for reference books);
  • Hierarchical totals;
  • Temporary tables and nested queries (SELECT * FROM (SELECT…)));
  • Query constructor - convenient, object-based, automatically optimizing the query text for quick reading, which can parse the query text (parse the query text and build an object model from it);
  • Report Builder is an add-on over the query engine, which has added the functionality of automatic presentation of results, as well as flexible configuration of the query itself in the "Enterprise" mode (ie by the user). As a result, a universal report appeared in standard 1C platforms, in which the user can configure what data and in what order he wants to see what is in the rows, what is in the columns, and the report itself generates the output table;
  • ACS (Data Composition System) is the next model that has incorporated the functionality of a universal report and supplemented it with some functions for processing results.

Programming language
In terms of syntax, 1C language is similar to "Russian Pascal", but differs from "Pascal" in less rigor and the absence of some constructions:

  • There is no need to declare variables - you can initialize directly in the text of the module;
  • There is no rigid typing of variables. The system has value types, but there are no strict typing rules for variables. The variable that stored the link can already store a number or a string in a couple of lines of code;
  • You can add variables with values ​​of different types, and the type of the result will be the same as the type of the first variable, for example:
    k = “25” +1; // k = “251”, not 26
  • Variables with values ​​of different types can be compared for equality or inequality (but not more or less, this will cause an exception) - naturally, such variables are not equal;
  • There are functions and procedures, it is permissible to use recursion (with limited recursion depth);
  • When specifying a function or procedure without parameters - all the same, be sure to indicate empty parentheses at the end: here_so ();
  • There are modules: each reference book and document has several of them, in addition, registers, reports and processing modules and each form have modules, and as part of the configuration, it is possible to create common modules;
  • No classes, inheritance, encapsulation, polymorphism;
  • The function cannot be passed as a reference, there are no anonymous functions;
  • There is no reverse loop (for i: = 5 downto 1 do), but it is really needed when deleting records. We get by with a slightly longer recording through the "Bye" cycle.

Tools

  • The 1C platform has the ability to unload and load a configuration, compare a configuration with another configuration and partially load changes;
  • It is possible to unload the texts of modules for batch processing and load them back into the configuration;
  • If the configuration is on support (all configurations from 1C are initially on support), then you can always compare and see what was changed by third-party developers or local specialists;
  • It is also possible to unload / load the entire database (along with data);
  • For collective work on one configuration, the configuration store is used;
  • There are also a number of rules for making changes to standard configurations, there is even a document from 1C that describes methods and standards for changing typical configurations (and any others).

General impression
The 1C language combines the clarity of the texts of the Pascal language with the frivolity of working with the variables of the BASIC language. It lacks a number of features inherent in modern programming languages, but it is quite possible to do without them. In addition, the 1C platform has a powerful garbage collector, i.e. there is no need, for example, to clear tables after use or to delete them.

1C Enterprise 8.2 interface

1C has paid special attention to the interface of its program. First of all, it is the color palette. She's gorgeous! The program windows are recognizable even from afar, while for many years of work - they do not cause hostile feelings, on the contrary - I want all programs to be as cool.
At the same time, the style of the platform is very strict, without frills and other frills. At the same time, there are very useful functions, for example, remembering the sizes of windows (the sizes are remembered only when they are changed by the user, and, at the same time, you can always reset the user settings - to the default sizes and positions by pressing Alt + Shift + R).
The 8.2 Web client interface raises a number of complaints, but the 8.3 platform seems to bring with it a new redesigned interface - Taxi.

Prices, supply and demand, franchising

The most "tasty" plus of the 1C platform is its price. This is especially true now, during the crisis. After all, 1C is completely our, domestic product. And it is sold for our wooden ones. Such solutions from a foreign manufacturer will cost a lot of money. And licenses for 1C are quite acceptable.

In addition, 1C has an interesting licensing policy. The licenses and configurations themselves are purchased once. At the same time, licenses are bought for a workplace and for a server, but not for databases, and not even for connections, i.e. under one license, the same user can run an unlimited number of 1C sessions, working with any number of databases. The same applies to configurations: by purchasing one license for a configuration, an organization can use it to create any number of databases; moreover, it is officially allowed to use parts of the code and objects of this configuration when developing its own configurations (while own configurations can be sold / transferred - stipulating that to use them, you need to buy a configuration from 1C).

After this one-time purchase, you only need to subscribe to updates and pay once a year to renew the subscription, the so-called. ITS. By the way, the subscription is very inexpensive, like two client licenses.

In general, it all looks very profitable.

The second "tasty", but already with a fly in the ointment, plus, is the presence of fairly universal configurations from 1C itself and from partners.

About versatility

The concept of "universality" was defined by one school teacher on CWP using the example of gas masks: there are universal ones that protect against many damaging factors, but the degree of protection is average or below average, and there are also specialized gas masks that protect against one impact, but with a high degree of protection. Until now, I have not come across a more precise definition.
And configurations from 1C are universal. Practically, there are no tasks where they could be fully used without modifications. Nevertheless, 1C has managed to create a universal set of tools that covers the needs of most branches of modern business.


The third plus (and also with a fly in the ointment) is the network of franchisees and training centers, both for users and for novice programmers and administrators. Good idea, but mediocre implementation quality. Nevertheless, the prevalence and aggressive marketing is one of the reasons for the widespread popularity of 1C in our country (and this is also the reason for negativity, envy and hatred).

A spoon of tar

Having painted 1C in all colors, it would be unfair not to say about its shortcomings, and they really are:

Unstable releases- both in the platform and in configurations, there are a huge number of errors and glitches. And this is in the official releases. Before the official version is released, a "Familiarization Version" is released. There is also feedback for submitting bug descriptions so that they can be accepted for correction. However, either the versions for acquaintance are not very popular, or the 1C company itself does not have time to process all the letters by the release date, but it is a fact. Each time you update the platform or configuration, you may stumble upon the most unexpected "surprises". The 1C company has already been repeatedly asked to test its developments more thoroughly.

Franchisee (hereinafter - franchise)... Ideally, according to the idea, these should have been firms with qualified specialists who know the basic principles of configurations and platforms. These same firms would have to sell the platform, configuration and support, slightly "finish" universal configurations to meet the client's requirements (and at times - adjust these requirements), trying to modify the standard configuration to a minimum. So as not to complicate too much future updates. In reality, the opposite is true.

When new licenses are sold to a client, francs receive 50% of their value (minus income tax 13% of this 50%). At the same time, you do not need to produce anything yourself, you just need to transfer the keys from 1C to the buyer.

When providing services, franches do not pay the 1C company anything (except for membership fees), but they need to pay an employee's salary. You also have to spend on taxes to the state - the FIU and income tax.

It turns out that both 1C and francs are profitable to sell licenses and unprofitable to provide further support. At the same time, in order for a client to buy a program, it must be initially adjusted to his requirements. And you have to pay for the work. And here, in order to save money, students, pupils, and non-specialists are attracted to whom you can pay a little, and sometimes not pay at all, they can not even be registered with the state (they will work unofficially, since there is something to pay for). The result is a huge number of sales with very low quality. Improvements tend to affect important mechanisms and complicate future updates. But at the stage of sale, neither 1C nor the franchisee is interested in this.

Note that this is not so much the fault of businessmen from franchises as of 1C. Focusing on sales, she did not take care of support at all (I'm not talking about schools now, but about the fact that it should be profitable for both the franchisee and 1C to provide support).

Technical support. In the understanding of 1C, technical support is providing access to the "update" section for the platform and configurations, as well as to information sections containing a description of some of the mechanisms and features of 1C operation. In addition, when subscribing, a disc with the specified materials is provided. There is also a forum (very scarce in comparison with the folk). It is also possible to send an e-mail to 1C - but without even hoping that they will be answered (or the robot will reply “The letter has been sent to the development department.” In terms of development, Yandex.Poisk and the help built into the configurator provide much more support.

Epilogue

I switched to 1C in 2008, and before that I worked in a company developing its own accounting program (Delphi 5, then Delphi 7). First, I got acquainted with the 1C Enterprise 7.7 platform and was amazed at the simplicity of developing reports in it. At the same time, it was clear that reports are generated much longer than in similar mechanisms on Delphi, but accountants did not particularly care. Wait a few minutes instead of a few seconds is not a problem. On the contrary, you can paint your nails there, drink some tea or discuss the latest news without stopping from work. After all, the overwhelming majority of accountants today are women.
However, the 7.7 interface was quite limited and the set of objects was quite sparse. I was looking for alternatives. I got acquainted with the external components, but they did not come to practical use, because the boss decided that it was time for us to switch to 8.1 (yes, 8.2 was not there yet), and in this platform, as a programmer, I found everything that I was missing earlier.
Currently, I have authority among colleagues, as well as clients who came to me from franches. They will probably never get in touch with francs again.


In general, I am quite satisfied with the work in the 1C Enterprise 8 platform. It is suitable for solving most of the accounting tasks and tasks using a database.

Tags:

  • programming languages ​​in Russian
  • 1C
  • 1C programming
Add tags

As a rule, learning any programming language begins with an example of writing the first simplest program (“Hello world!”). This is done in order to clearly show how to work with basic syntactic constructions. We will not make an exception to this generally accepted way of presenting material when exploring a new development environment, and therefore our first article should be viewed in the same vein. In it we will analyze in detail the answers to the following questions regarding programming on the 1C: Enterprise 8 platform:

  • Where and with what help to write the program code in the built-in 1C language?
  • What are software modules, what are the rules for working with them?
  • What is a variable, how to work with it, how and where to declare it?
  • What comparison, assignment, and conditional operators are there, and how do you apply them?
  • Boolean operations - what are they and how to work with them?
  • Why are loops and how to use them?

The article will be useful to all those who are not yet familiar with development on the 1C: Enterprise 8 platform, but want to learn how to program on 1C.

Applicability

The material is relevant for the 1C: Enterprise 8 platform, edition 8.2. and 8.3.

Variables and Operators

In this article we begin to study the built-in language 1C: Enterprise 8. The executable code is contained in program modules.

There are a large number of modules that are designed to handle various events.

So, the user's login to the system is processed in one module, and the processing of the user's clicking on a certain button is processed in a completely different one.

Thus, each module describes the behavior of the configuration at a certain point. The module contains, first of all, a section describing variables. Those. we can declare some variables in the module.

Later they can be used in the procedures and functions of this module. If a variable is defined with the Export keyword, then it will be available outside this module. An example of a variable declaration line:

Change Warehouse, Division, Storekeeper Export;

After the declaration of variables, there is a section of procedures and functions.

Behind them is the section of the main program, which will be executed at the time of access to this module.

For example, in the section of the main program, you can initialize variables, i.e. assign them some initial values:

State = 1;
NewExpression = 2;
Result = 3;

A module can be thought of as a combination of different operators that perform different actions we need.

The operator separator is the character ";" (semicolon). This character is the end of the statement. Those. the operator can be written as follows:

Result = 100X200
+400
-600;

It doesn't matter how many lines the operator is on.

Of course, more often it is more convenient and clearer to place an operator in one line, but sometimes the operators are quite long (the number of lines can reasonably reach several dozen).

The semicolon can be omitted in the final statement of a given construct, for example, a procedure. Those. the following code will work:

Procedure CalculateValues ​​()

InitialValue = 100;
IntermediateValue = InitialValue / 5;
TotalValue = InitialValue + IntermediateValue

End of Procedure

However, it is better to use a semicolon in the trailing statement. It is possible that over time, the construction will be continued, and the final statement will no longer be final. We'll have to specifically monitor this situation.

Variables are designed to store some values ​​of any data type. They are used for intermediate storage of information for processing.

In almost any program module that performs some action, there are various variables. The typing of variables by values ​​in Platform 1C: Enterprise 8 is soft.

For example, a variable can contain a value of one data type, and a few lines later - another type:

Created = False;
Created = True;
Created = 100;

In the first two operators the value of the variables is Boolean, and in the third it is changed to a numeric value. Those. typing depends on the value that is assigned to a given variable.
Variables can be described in two ways:

  • implicit way (the mention on the left side of the assignment operator describes the given variable, there is no preliminary description of the variable with the word Var, i.e. there is no special section for describing variables);
  • explicit description of variables (Variable ControlData;). Explicit declaration of variables is used, for example, if the subsequent transfer of this variable to a function is expected.

For the names of variables, the classic description of the identifier is used. The identifier consists of letters, numbers and underscores. The identifier must begin with either a letter or an underscore.

In this case, the name of the variable should reflect the meaning of this variable. Single letter variable names (like A, B, C) are bad examples. They do not reflect the nature of the variables.

Examples of correct variable names: Counter (increasing variable for a loop), Counterparty. If a variable name contains several words, then each new word, for clarity, should start with a capital letter.

Reserved words such as Procedure, Function, Loop, End of Loop, etc. cannot be used in variable names. (these constructions are highlighted in red in the program module).

Reserved words are built-in language operators and there are quite a few of them. All of them are presented in Syntax Assistant.

It should be noted that data types are not reserved words (for example, Array, Boolean, True, False). The system will accept such variable names correctly.

For writing program code, the case does not matter. For example, the word Procedure can be written with both capital and small letters. Moreover, uppercase and lowercase letters can be alternated within a word.

It doesn't matter to the Platform. Nevertheless, according to the rules of good form, the beginning of a word must be written with a capital letter, all other letters in small letters.

About the language. You can use both Russian and English, and a combination of two languages. If it is convenient for someone, you can safely use English to write program code, as well as combine Russian and English. This is not important for the Platform.

Many names in English are difficult to remember. When using a combination of two languages, the readability of the program code deteriorates.

Boolean operations

Comparison operators often use Boolean logic that returns True or False.

For example, in the conditional operator you can compare: If Event = Sale Then the algorithm will follow one branch (ie, if the value is True), another branch of the algorithm is executed by the False condition.

Conditions can be quite complex, they can be combined, and the following operators are applied: AND, OR, and NOT. So, for the AND operator:

Truth And Truth = Truth;
True And False = False;
Lies And Truth = Lies;
Lies AND Lies = Lies.

For the OR operator, it is enough that one of the operands is True, then the value of the combination will be True. The value is False only when both operands are False.

The operator does NOT simply invert the current value (False to True, True to False).

Using a combination of these operators, you can build quite complex conditions. When constructing complex conditional statements, consider the precedence.

The NOT operator has the highest priority, followed by the AND operator, followed by the OR operator. What is in parentheses has the highest priority and gets executed first.

For example, let's prioritize (sequence of execution) for the operations in the above expression:

NOT (Condition1 OR Condition2) AND Condition3 OR Condition4
1.Result1 = (Condition1 OR Condition2);
2. Result2 = NOT Result1;
3. Result3 = Result2 AND Condition1;
4. Result = Result3 OR Condition4;

There is a conversion rule:

NOT (Condition1 OR Condition2) = NOT Condition1 AND NOT Condition2.

However, one should not always strive to simplify the expression, because often, logically, the expanded expression is easier to read.

Assignment operator

The assignment operator should not be confused with equality, even though they have the same spelling.

The principle of the assignment operator is such that the left value (the variable on the left side) is assigned the value that is to the right of the equal sign. Let's look at an example:

Variable1 = Variable2 = Variable3;

Variable1 is assigned an equality value from Boolean logic, i.e. True if Variable2 = Variable3, or False otherwise.

When testing for the position of a novice programmer, the task is often used: to swap the values ​​of two variables in places.

This problem is solved using the assignment operator and has two solutions.

Solution # 1 using a temporary variable:
TemporaryVariable = Variable1;
Variable1 = Variable2;
Variable2 = TemporaryVariable;

Solution # 2:
Variable1 = Variable1 + Variable2;
Variable2 = Variable1 - Variable2;
Variable1 = Variable1 - Variable2;

Conditional operator

There is such operator If, after which it is necessary to describe some condition (the condition itself can be quite large). The condition is followed by the word Then and the executed operators.

This may be followed by the keyword Else and a series of other operators. If there are several different conditions, you can use a series of keywords Otherwise, if(see example below). The whole construction must end with a keyword End If followed by a semicolon.

In addition to simple and multiple conditions, there is an abbreviated form of the conditional operator:? (Condition, Expression1, Expression2);

If the condition is true, then Expression1, otherwise - Expression2... Example code: DearProduct =? (Product.Price> 100000, True, False);

In practice, instead of comparison records with value True (Lie) type:

If Variable = True Then
and
If Variable = False Then

the equivalent records are actually used:

If Variable Then
and
If NOT Variable Then

Cyclic Operators

For any type of cycle, it is necessary to explicitly indicate the end of this cycle using the keyword End of cycle... There are several types of loops.

Cycle over counter- a cycle with a fixed number of repetitions. The condition for exiting the cycle is exceeding the limit value. An example of use for calculating the value of A!

A = 5;
Factorial = 1;
For Counter = 1 By A Cycle
Factorial = Factorial * Counter;
End of Cycle;

Conditional loop- is executed as long as the condition of the given cycle is true. Example:

Remaining Amount = 1000;
Additional Product Price = 243;
Quantity = 0;
While RemainderSum> 0 Cycle
Quantity = Quantity + 1;
Amount Balance = Amount Balance - Quantity * Additional Product Price;
Additional Product Price = Additional Product Price * 0.8;
End of cycle
Quantity = Quantity-1;

This cycle calculates how many units of a product can be bought for a given amount (1000 rubles) if after buying each unit of a product its previous price is multiplied by a factor of 0.8. The original price of the product is 243 rubles.

An example of an error when using this type of loop for beginners is an eternal loop, when initially the loop condition is true, but within the loop itself it does not change in any way.

Loop through collections (another name for each).

The Platform has a fairly large number of collections (these are containers that contain elements of a certain type).

You can traverse the elements of a collection using a special kind of loop.

For example, there is an array of numbers, you need to calculate the sum of all the elements of the array:

Amount = 0;
For Each Item From Array Loop
Sum = Sum + Element;
End of Cycle;

There are special operators for loops: Continue and Abort.

If at some point in the cycle the execution of further operators of this iteration becomes meaningless, then to return to the beginning of the cycle and organize its next iteration, the operator Continue.

Operator Abort allows you to terminate the execution of the loop, even if the loop condition is true.

This concludes our first acquaintance with the development in the internal 1C language.

What about Hello World? We haven't written it yet, have we? Yes, but nothing prevents you from doing it yourself, because knowledge is ALREADY enough. Well, if it doesn't work out, then you can peep here.

In this article, we will consider such a construction of the 1C programming language as Cycles.

There are three ways to organize loops.

  1. Loops using boolean expression (executed as long as boolean expression is true)
  2. Loop through collections

Let's take a look at each of these methods.

Loops using a variable - loop counter

Syntax:

For< Переменная> = < НачальноеЗначение>By< КонечноеЗначение>Cycle End of Cycle;

With this method of organizing loops, the counter variable is assigned an initial value and it is executed until the value of the counter variable is less than or equal to the specified final value.

With each iteration, the counter is incremented by one. Here is the most basic example of such a loop:

For Counter = 0 By 1000 Cycle End of Cycle;

Unlike many other programming languages, 1C does not provide for the ability to specify a step in a loop. If necessary, this can be done by adding the desired value to the counter inside the loop.

For Counter = 0 By 1000 Cycle Counter = Counter + 10; End of Cycle;

Loops using a boolean expression

Syntax:

Till< ЛогическоеВыражение>Cycle End of Cycle;

Refusal = False; GeneratorCh = New Generator of RandomNumbers (1); Until NOT Failure Cycle RandomNumber = RTC Generator. RandomNumber (0, 10); If RandomNumber> 5 Then Failure = True; EndIf; End of Cycle;

That is, the loop will run until a random number greater than five is generated.

Loop through collections

In the 1C programming language, there is such a concept as a collection. It is a collection of elements contained within an object.

We can refer to a collection such objects as: an array, a table of values, a selection from a query result, metadata, etc. This concept is rather arbitrary, but it is found in the syntax helper at every step. A very common task is when we need to sequentially iterate over all the elements of a collection in order to perform some action on them. For this, there is a syntactic construction:

For everybody< ЭлементКоллекции>From< Коллекция>Cycle End of Cycle;

Here <ЭлементКоллекции> Is a variable into which elements from the collection are sequentially placed. And within the loop, it is handled accordingly.
As an example, I will give a looping through the rows of a table of values. Let her be called TableProducts and looks like this:

Let's go around this table in a loop and for each line we will display a message with the name and price of the product:

For each TableRow From TableProducts Loop Name = TableRow. Name; Price = TableRow. Price; Message = New Message to User; Message. Text = "Name of product: "

In fact, the same can be done using the first option, that is, in a loop using a counter:

Number of Rows = Table Items. Quantity() ; For Counter = 0 By Number of Lines - 1 Cycle TableRow = TableProducts [Counter]; Name = TableRow. Name; Price = TableRow. Price; Message = New Message to User; Message. Text = "Name of product: "+ Name + "; Price:" + Price; Message. To report() ; End of Cycle;

But as you can see, it is much easier and more convenient to use traversal of collection elements.

Auxiliary Operators

There is often a situation when, depending on some one, it is necessary to interrupt the execution of the loop, or to move from the next iteration.

Interruption is carried out with the help of the operator Abort... In this case, the execution of the loop is interrupted and control is transferred to the language construct following the loop. If you need to go to the next iteration, you must use the operator Continue... Then control is transferred to the beginning of the cycle. Let's illustrate with a small example:

For Counter = 0 By 100 Cycle If Counter = 0 Then Continue; EndIf; If Counter = 4 Then Abort; EndIf; Result = 1 / Counter; Message = New Message to User; Message. Text = String (Result); Message. To report() ; End of Cycle;

We skip zero, because You cannot divide by zero. And in total, the loop will be executed five times, for the values ​​of the variable Counter from 0 to 4

The 1C programming language is a formal sign system designed for writing computer programs. A programming language defines a set of lexical, syntactic and semantic rules that determine the appearance of the program and the actions that the executor (computer) will perform under its control.

The 1C Enterprise 8 platform has full functionality for developing its own solutions for the developer. The main development tool is the built-in 1C 8.3 programming language.

The creation of new classes programmatically in the 1C 8.3 language is prohibited. Since the 1C Enterprise platform is specialized for accounting tasks, the composition of the classes is predetermined in advance:

  • etc.

Based on typical classes, you can create any number of subclasses that have their own sets. With the help of manager modules, you can slightly expand the functionality of the subclass.

Is the 1C programming language complicated?

The question is rather controversial and relative. When viewed in relation to other languages, it may seem a little simpler. However, in addition to programming itself, you will have to study the subject area - accounting, production, tax accounting, etc., which makes the 1C programming language as a whole not as simple as it might seem at first glance.

If you had a solid experience in other domain-specific programming languages ​​before acquaintance with 1C, it will not be difficult for you to understand the intricacies of 8.2, the main thing is desire. All you need is to find a good tutorial on the 1C programming language.

Russian syntax of 1C language

Top related articles