How to set up smartphones and PCs. Informational portal
  • home
  • Safety
  • Using conditions if in 1s. Logical operations (1c enterprise)

Using conditions if in 1s. Logical operations (1c enterprise)

The following apply logical operations:

NOT logical NOT (negation); AND logical AND;

OR logical OR.

The operands of logical operations must be logical expressions. Table 2.5 shows the results of logical operations on logical expressions ЛВ1 and ЛВ2, taking values true(And) or Lying(L).

Truth table

Table 2.5

LV1 LV2 LV1 AND LV2 LV1 OR LV2 NOT LV1
AND AND AND AND L
AND L L AND L
L AND L AND AND
L L L L AND

The negation operator is a unary operator to the left of the operand. All other considered operations are binary.

2.6.5. PERFORMANCE PRIORITY

All 1C operations are performed in an expression from left to right in accordance with their priority (seniority), that is, if two consecutive operations have equal priority, the left operation is initially performed. Parenthesized subexpressions are evaluated first. Table 2.6 1C operations are arranged in descending order of their priority.

Priority of operations

Table 2.b

% *, / +, NOT AND OR<, <=, >, >=, =, <>

Comment. Each cell in the table contains operations with equal priority.

Example:

8 % 2 * 3 // Will return 0
8 % (2 * 3) // Will return 2

Since logical operations are older than relation operations, the following logical expression is erroneous:

3> 2 and 4< 5 // Так неверно

since the boolean subexpression 2 and 4 is initially evaluated

which operands are not true or Lying. And this is not true.

But the logical expression is correct

(3> 2) and (4< 5) // Это true Example. Evaluate the result of a boolean expression

(x / a = 1) or (b / (a ​​+ b)< 1) и не (б = а) или (х <>6) at x = 6.0, a= 2.0 and b = 3.0.

Having calculated the result of the operations of the subexpressions enclosed in parentheses, we get:

Lying or true and not Lying or Lying.

Lying or true and true or Lying. After execution true and true: false or true or Lying. Final Result: true.

2.7. ARRAYS

Array it is a data object containing several values, which are accessed by their number ( index).

The number of elements in the array is called it size. The size of an array can only be an integer literal constant.

Variable operator;

declares a one-dimensional array (vector) a of five elements. Array elements have the following names: a, a, a, a and a. In these names, the values ​​1-5 are the indices of the array elements.

An array is considered definite if the values ​​of all its elements are specified. To set the initial values ​​of array elements (array initialization), the following loop is possible:

for in = 1 to 5 cycle

Assignments

change the values ​​of the 2nd and 5th elements of the array, respectively a.

In general, numeric expressions called index expressions. For instance:

a = 9.1; // Change the value of the 3rd element of the array a

If an array index expression is evaluated with a non-integer value, then the integer part of this value is taken as the index. For instance:

a = 9.1; // Change the value of the 1st element of the array a

The index value must not exceed the boundaries of the array. So, when working with a previously declared array a five-element statements are erroneous

Elements of the same array can be of different types. For instance:

a = ‘25 .11.01 ’; // Element of type Date Array elements can be of aggregate type. For instance:

sSotr = CreateObject ("Directory.Employees");

table = CreateObject (“Table”);

An array cannot contain other arrays as elements.

An array can be a formal parameter of a software component (procedure or function). In this case, the size of the array is not specified, and the square brackets are preserved. To determine the size of the array passed to the procedure (function), use the built-in function Resize.

Example:

procedure Initialization of Array (a) variable, size;

size = Size (a); // The built-in function Resize will return the size of the array a

for in = 1 by size cycle

a [in] = 1; // Now all elements of the array are equal to one end of Loop;

endProcedures // Array Initialization

procedure Execute () change;

// Call a procedure that sets the initial values ​​of array elements

// Its actual parameter is the name of the array Array Initialization (a);

endProcedure // Execute

Now the 1C program exists in different versions and guises, people work in the "seven" ie in 1C 7.7 and in the "eight" which are 8.0, 8.1, 8.2 and 8.3. In practice, at the moment 99.9% of users of the 1C program work in 7.7, 8.2, and 8.3, how are they different?

The 1C 7.7 program is known to many for its already rather outdated interface, nevertheless it has an advantage in the size of the bases and in the speed of launching and working, which means it has a place to be on the market of accounting automation programs, although now this program is no longer sold, but people are used, and 1C still supports this program, i.e. updates are coming out for her.
But the topic of the article is still not about 7.7, but about the differences between 8.2 and 8.3. (and for information, the difference between 7.7 and 8. * is significant so much that the bases for the seven will not start on platform 8. * and vice versa, i.e. 7.7 and 8. * are, as it were, completely different programs, but 8.2 and 8.3 are very similar, just 8.3 is newer)

The 1C program consists of a 1C platform and 1C bases, i.e. 1C platform is a program that launches 1C databases.

For the user: when we click on the 1C shortcut and a list of 1C bases opens, we see a part of the 1C platform, or when we select the base and click on the "Configurator" button ie. we go into the 1C configurator, we can also say we see part of the 1C platform, but when we open the database by clicking on the "1C: Enterprise" button, we already see the base, with its settings, "menus", buttons, pictures, etc. then this is already a 1C base which is different depending on its type, i.e. configuration base 1C
The 1C base consists of a configuration (i.e. its settings) and data (i.e. information in it).

There are different 1C configurations for different accounting, i.e., for example, for accounting there can be a configuration called "Enterprise Accounting" or others, for trade, a configuration can be used, for example, "Trade Management" or "Retail" or others, for personnel accounting and payroll, such as Payroll and Human Resources, there are also configurations for complex accounting, such as plant automation.
There are many configurations, several hundred different configurations for different accounting.

All these configurations can be created to work in 1C 7.7 or 8.2 or 8.3, what are the differences and why is it written here about configurations if 8.2 and 8.3 and even 7.7 are platforms? Let's figure it out now.

Each platform has different possibilities for creating configurations, and the higher the version of the platform, the more functionality and capabilities this platform has.
If we need a 1C database with a configuration, say "Enterprise Accounting", with a release version, for example, "3.0.60.44" and we will try to find information about it, then we will find out that for this configuration and this release to work, we need a platform no lower than 8.3, more that is not lower than 8.3.10.2466, which means the 8.2 platform will no longer suit us!

There are many configurations for the 1C 8. * platform, but they can be divided into 2 subspecies, these are configurations (1) with "regular forms", and (2) with "managed forms"
"Regular" means the same as they were before, for example, similar to 1C 7.7, and "Controlled" are more modern forms, more beautiful, which are easier to control when creating them.

How can I understand normal or managed forms in my 1C database?

If at the top of the program you see a line of "menus" with names such as "File", "Edit", or "Operations", "Service", "Windows", "Help", and most importantly you can click on them and down "will drop out »Submenu with a choice of sub-items, then you have a configuration with regular forms.

If you do not have such "menus" at the top, but there are links at the top or on the left or in other parts of the program, on the website, i.e. you point at them and they immediately become underlined, they may have names such as "Main", or "Sales", "Purchases", "Administration" or "NSI and Administration" or other similar links or pictures, and when you click on they do not "drop" a list of submenus, but an information or a separate window opens in the center of the program, so you have a configuration with "managed forms", they are usually more beautiful and modern in appearance. If you know that you have a Taxi interface, then these are precisely managed forms.

Earlier, when the 8.3 platform did not yet exist, but there was only 8.2 and ordinary forms, then configurations on managed forms had just begun to be developed, the 8.3 platform appeared, and a little later, many people began to associate the 8.3 platform with managed forms, and already the 8.2 platform with the usual ones. So the notion that someone 1C 8.2 (i.e. 1C base with configuration on regular forms), and someone 1C 8.3 (i.e. 1C base with configuration on managed forms).
In fact, platform 8.3 is newer than 8.2, which means it can work with all configurations for 1C 8. *, BUT! If you have a 8.3 platform, and a base with a configuration on ordinary forms, then they can say about you that you have 1C 8.2 and it is important to understand this!

It is also important to understand that you can have a platform 8.2 and the configuration on managed forms, then they can say about you that you have 1C 8.3! For many, it is faster, more convenient and more familiar.
Those. most of them do not care what platform they have and if they have a base with conventional forms, then this is 1C 8.2! if with controlled - then 8.3!

Based on this fact and the established opinion in terms, on our website you can find processing 8.2 or 8.3, this does not mean that what platform you have is important for processing, it means that it, processing will work either in the database with regular forms or only with managed, and there are also universal treatments in their name will be written (8.2 and 8.3) or (8.2 / 8.3) or (8.2-8.3) or (8. *)

Below are examples of some popular 1C configurations on conventional forms, i.e. called 1C 8.2:
- Accounting by an enterprise 2.0. *. *
- Trade Management 10.3. *. *
- Retail 1.1. *. *
- Salary and personnel management 2.5. *. *

Now examples of some popular 1C configurations on managed forms i.e. these are called 1C 8.3:
- Enterprise Accounting 3.0. *. *
- Trade management 11. *. *. *
- Retail 2. *. *. *
- Salary and personnel management 3. *. *. *
- Management of our company 1.6. *. *

A short version of the entire article or an answer to the question: what is my 1C 8.2 or 8.3?

If you have a 1C database after you open it at the top there is a line from the "menus" with names for example "File", "Edit", or "Operations", "Service", "Windows", "Help", and when you click down, a submenu with a choice of sub-items will "drop out", then such a base is called 1C 8.2 and only those processing, reports, extensions, the names of which have "8.2" in their names, will not work, and those processing, the name of which has "8.3"

If there is no such line from the "menus", but there are links, when you hover over which these links are immediately underlined, they may have the names Main "or" Manager "or" Sales "," Purchases "," Administration "or" NSI and Administration " or other similar links or even pictures. means - this is the base 1C 8.3 and for it only those processing, reports, extensions, in the names of which there is "8.3" and those processing in the name of which there is "8.2"

The exception is universal processing, reports in the names of which are both 8.2 and 8.3, i.e. the name will say (8.2 and 8.3) or (8.2 / 8.3) or (8.2-8.3) or (8. *)

Various functions can be applied to query fields. In this section I will consider the most frequently used (by me personally) of them.

DATE TIME- specifies a constant field of the Date type. Syntax:

DATE TIME(<Год>,<Месяц>,<День>,<Час>,<Минута>,<Секунда>)
Request.Text =
"SELECT
| DATE TIME (2013, 1, 1) AS OMG "; // January 1, 2013

DIFFERENCE- returns the difference of 2 dates in the specified dimension (year, month, day, hour, minute, second). Syntax:

DIFFERENCE (<Дата1>, <Дата2>, <Тип>)
Request.Text =
"SELECT
| DATE DIFFERENCE (DATE / TIME (2013, 2, 28), DATE / TIME (2013, 1, 1), DAY)
| AS DAYS TO END WINTER ";

MEANING- sets a constant field with a predefined record of one of the database tables, you can also pass an empty link. Syntax:

MEANING(<Имя>)
Request.Text =
"SELECT
// predefined catalog item
| VALUE (Directory.Currencies.Rules) AS Ruble,
// empty link to the document
| VALUE (Document.InvoicePayment to Buyer.EmptyLink) AS EmptyInvoice,
// enumeration value
| VALUE (Enumeration. Gender of individuals. Male) AS Male,
// predefined account from chart of accounts
| VALUE (Plan of Accounts. Self-supporting.Goods) AS Account_41 ";

CHOICE- an analogue of the IF construction for the 1C query language. Syntax:

CHOICE
WHEN<Выражение>THEN<Выражение>
OTHERWISE<Выражение>
THE END
Request.Text =
"SELECT
// if the price is less than 100, then the request will return 100 anyway
// otherwise the request will return the real price
| CHOICE
| WHEN Goods.Price> 100
| THEN Goods.Price
| ELSE 100
| END AS Price
| FROM

LINK<Имя таблицы>
Request.Text =
"SELECT
// if the value type of the registrar is document Receivable,
// then the request will return "Goods receipt", otherwise "Goods sale"
| CHOICE
| WHEN Leftovers.Registrator LINK Document.Incoming
| THEN "" Goods receipt ""
| OTHERWISE "" Sale of goods ""
| END AS Kind of Movement
| FROM
| Accumulation Register. Balances AS Balances ";

BETWEEN- checks the value for entering the range. Syntax:

BETWEEN<Выражение>AND<Выражение>
Request.Text =
// get all products in the price range from 100 to 1000
"SELECT
| Goods. Commodity
| FROM
| WHERE
| Goods. Price BETWEEN 100 AND 1000 ";

V and IN THE HIERARCHY- check for the presence of a value in the transmitted list. In the HIERARCHY, it also expands hierarchical items downward and searches for meaning among subordinate items. Syntax:

V(<СписокЗначений>), IN THE HIERARCHY (<СписокЗначений>)
Request.Text =
// get all sub-accounts of 41st and 10th accounts
"SELECT
| Self-supporting.Link AS Account
| FROM
| Plan of accounts. Self-supporting AS Self-supporting
| WHERE
| Self-supporting.Link IN THE HIERARCHY (VALUE (Plan of Accounts. Self-supporting.Goods),
| VALUE (Plan of Accounts. Self-supporting. Materials)) ";

LIKE- allows you to compare a string against a pattern, used when the search string is not hard-coded. Building a template:

  • % (percent): a sequence containing any number of arbitrary characters
  • _ (underscore): one arbitrary character
  • [...] (one or more characters in square brackets): any single character listed within square brackets. Ranges can be specified in the enumeration, for example a-z, which means an arbitrary character included in the range, including the ends of the range
  • [^ ...] (a negation sign in square brackets followed by one or more characters): any single character other than those listed following a negation sign

Syntax:

LIKE "<ТекстШаблона>"
Request.Text =
// find all chairs in the nomenclature directory
"SELECT
| Goods. Commodity
| FROM
| Directory.Products AS Products
| WHERE
| Products. The name is LIKE "" tool% "" ";
// this query will return Chair, chair, high chair, office chair, etc.,
// but the table will not be in this list

IS NULL- if the field is not defined, then defines it in the specified expression. Syntax:

ISNULL (<Выражение>, <Выражение>)
Request.Text =
// If the field is not defined (NULL)? then assign it an empty link
"SELECT
| IS NULL (Products.Ref, VALUE (Directory.Products.EmptyLink)) AS Product
| FROM
| Directory. Goods AS Goods ";

Note that NULL should be handled without fail, since this is a very "capricious" type (in the "1C: Enterprise 8" system, a special type NULL with one element is defined). If you try to compare with a value of this type or assign it, you will surely run into an error, so do not forget about this construction. When NULL may pop out:

  • after joining tables, except for the internal one (the next article is about joining);
  • after selecting the requisites defined only for groups of directories and vice versa;
  • after selecting the column of the journal of documents, while the current document does not have the details included in this column.

This is not a complete list of functions of the 1C 8 query language, if you are interested in the work of any others, write in the comments.

Hello dear readers. I have already written about such primitive data types as NULL and String, but today we will consider a primitive data type Number.

Numeric we can have a props of a configuration object or variables in.

The maximum number of digits is 38 characters, the length of the integer part cannot exceed 32 characters, the precision is 10 characters. Although in variables it is possible to operate with numbers exceeding 38 characters, but in IB (information base) we can write values ​​with a long integer part of no more than 32 characters.

The following operations are applicable to data of a numeric type: +, -, *, /, (),% (modulo 10% 3 = 1).

Mathematical functions for numbers can be viewed in the syntax helper
General description of the built-in language-> Built-in functions-> Functions for working with the Number type

Of all the functions that are given there personally, I have so far only had to work with two:
Okr (<Число>, <Разрядность>, <РежимОкругления>) The function rounds the original number to the required bit depth in accordance with the specified rounding mode.
Parameters:<Число>(required) Original number. The rest of the parameters are optional.

// Round up the price to kopecks RoundedPrice = Okr (Price, 2); // Round up the price to hundreds of rubles RoundedPrice = Okr (Price, - 2);

Int (<Число>) - The function calculates the integer part of the passed number, completely cutting off the fractional part.

Example: You Can Buy = Intact (Availability / Price);

If you have encountered other functions in tasks, write examples in the comments.

Often in practice, there is a conversion of data types from a string to a number, for these purposes there is the Number () function.

Function Number ()- Converts the received parameter (the parameter is usually a string type) into a value of the Number type.
Example: CheckNumber= Number (Rights (InsuranceNumber, 2));

The Boolean type is converted to a number:
False is converted to 0;
Truth is converted to 1.

Arithmetic priority:
1) ()
2) Unary arithmetic operations (+, -)
3) *, /, %
4) Binary arithmetic operations (+, -)
5) Comparison operations (>,> =,
6) NOT
7) AND
OR

I will give a couple more functions that are useful when working with Number

Format(<Значение>, <ФорматнаяСтрока>) The function generates an easy-to-read representation of the values.
Parameters:<Значение>(required) Parameter type: Number; Date; Boolean.

It is convenient to set a format string by calling: Format string constructor

Max(<Значение1>,…,<ЗначениеN>) The function determines the maximum value from the received parameters.
Parameters:<Значение1>,…,<ЗначениеN>(required) and can have one Type: Number; Line; Date; Boolean.

Example:
// Example for numbers

A = Max (1, 2, 3); // A = 3

Min (<Значение1>,…,<ЗначениеN>) From the obtained parameters, the function determines the minimum value.



Full syntax (click to expand)

Conditional "If" operator

Description:

Operator If controls the execution of a program based on the result of one or more logical expressions. An operator can contain any number of operator groups headed by constructs Otherwise, if - Then.

Syntax:

Parameters:

If is a Keyword that begins the structure of a conditional execution statement.<Логическое выражение> Boolean expression. Then Operators following Then are executed if the result of a boolean expression is a value True. // Operators An executable operator or a sequence of such operators.Else If the Boolean expression following the keyword Otherwise, if, is calculated only when the conditions in If and all previous Otherwise, if turned out to be equal Lie... Operators following a construct Otherwise, if - Then, are executed if the result of the boolean expression in the given Otherwise, if is equal to True. Otherwise Operators following the keyword Otherwise, are executed if the results of the boolean expressions in the construct If and all previous constructions Otherwise, if turned out to be equal Lie. EndIf A keyword that ends the structure of a conditional execution statement.

Ternary conditional operator

Description:

Evaluates one of two specified expressions depending on the result of evaluating a Boolean expression.

Syntax:

? (< Логическое выражение> , < Выражение 1 > , < Выражение 2 > )

Parameters:

Returned value:

The result of evaluating one of the resulting expressions.

& OnClient Procedure ExecuteCode (Command) /// How to compose an operator If in 1s 8.3, 8.2 If 1> 0 Then // True // statement block To report( "The computer will execute all commands from this block."); To report( "One is greater than zero."); EndIf; If 1< 0 Тогда // Ложь Сообщить("One is less than zero."); Otherwise Report ( "It is this branch of the conditional operator (#A) that will work."); To report( "One is greater than zero."); EndIf; If 1< 0 Тогда // Ложь Сообщить("One is less than zero."); ElseIf 1 = 0 Then // False Report ( "One is zero."); Otherwise Report ( "It is this branch of the conditional operator (# B) that will work."); To report( "One is greater than zero."); EndIf; /// How do I compose a ternary operator? in 1s 8.3, 8.2 Text =? (1> 2, "One is more than two.", "One is not more than two."); Report (Text); // will print "One is not more than two." End of Procedure /// Download and run these examples on your computer

Top related articles