1. In order for the price to be inserted in the tabular section after selecting an item item, and the total amount to be calculated when entering the quantity, it is necessary to: specify the names of event handlers in the necessary properties of the corresponding columns - 2. The concept of “Data” for form controls does not include: variables, defined in the module of this form+ 3. Form attribute: available in the context of this form 1. To process an event on a control, you can define: only one event handler+ 2. How to create a form attribute?: add a control and specify it in the "Data" property the name of the new attribute - in both ways 3. In Configurator mode, how can you visually check the effect of the bindings on how the form will look when its size is changed in 1C:Enterprise 8.0 mode? Form menu item Check+ 4. Where is the description of the event handler "Click" of the dialog button located: in the form module+ 5. When designing a form dialog, you can define... any number of form elements associated with the same data element+ 6. In the “Data” property of a form element cannot be selected: an attribute if it is of the “Value Storage” type + 7. When does the “When a row is activated” event occur? when moving to another list line + 8. How to make the Separator form element invisible in Configurator mode? select the No frame value for the Form element Frame property+ 9. The main form attribute...is absent for forms of arbitrary type+ 10. Event handlers in the form module can be defined: for tabular parts 11. When designing a form dialog, you can define... only one form element associated with one data element - 12. In the "Data" property of a form element you cannot select: attribute if it is of the "Value Storage" type + 13. Non-standard decoding order: available in the module of the corresponding object - 1. Event handlers in the form module can be define: for object details - 2. Which control element allows you to change the relative arrangement of fields? separator+ To access in a form module (event handler) the data of the current row (selected by the user) of the tabular part of an object, you must: use the properties and methods of the form, form elements - / access directly by the name of the tabular part attribute in the context of the current row - / access through a dot on behalf of the tabular part (Products.Nomenclature) - In the application module...: there are no restrictions on the description of variables, procedures, functions + Is it possible to programmatically delete a form element in the dialog? : not possible - / only possible if it is programmatically added. Is it possible to allow a form to be “hiding” (.AllowHidingState=True;)?: only possible before opening the form+ An object property can be accessed through: parentheses: Object[PropertyName ]- both When programmatically searching for a directory element, if nothing is found with the specified parameters, the method will return... an empty link + To access predefined element directory you need to: find it by name: Directories.DirectoryName.ElementName+ B common modules...: there are no restrictions on the description of variables, procedures, functions - When can you refuse to write an object in an event handler?: either in “before writing” or “while writing”: all + When writing a document (in any form of the document) ...: initially the "On writing" procedure of the object module is executed, then the "On writing" event handler of the form+ To output the value of the variable to a spreadsheet document (print) / get a named area, write the value of the variable to the parameter of the resulting named area and then include region in spreadsheet document+ Which of the following lines cannot be used in an outer join module? SprObject = Directories.Nomenclature.CreateElement() - When defining procedures and functions...: the order in which the descriptions of procedures and functions appear does not matter + 1. The resource of the information register can be of the type: any + 2. The resource of the accumulation register can be of the type : numeric+ 3. Objects of the type: all+ can have a subordinate object “Dimension” 4. Objects of the type: all can have tabular parts + 5. When writing to the accumulation register, the date of movement: is strictly tied to the date of the document, if the document is posted promptly - 6. Document posting option (promptly or not) ... to track the posting option, you need to contact the corresponding global context method - / a parameter with the posting option is passed to the posting module 7. To view document movements by any register, it is necessary. ..: use the “go” button in the journal toolbar + 8. When defining the directory in the configurator, it was indicated that it can be edited “in both ways”. Can a user, working with a certain list form, change the editing method (from “in the list” to “in the dialog”)?: cannot - / button 9. Direct deletion mode in user mode ...: available for both types of objects + 10. Typing text in a field that has an aggregate value type (Nomenclature directory) ...: unacceptable - 11. When carried out in Non-operational mode... when using data from registers, data that is relevant only at the moment is automatically obtained posting a document - / when using data from registers, you need to obtain data that is relevant only at the time of posting the document 12. When you specify the document property "Delete movements" to the state "Do not delete movements automatically" ...: automatically removes the right "Cancel Posting" - when reposting the document, they stop automatically delete its old movements - 13. If a document in the configurator is allowed to be processed quickly, then... the document can be processed only for the current date and current time - 14. When recording information in the register (with frequency according to the registrar) on arbitrary dates (other than date of the document) in the "Period" field there will be: recorded date 15. Changing the boundary of the calculated balances for the corresponding accumulation registers is done... at the discretion of the user + When specifying the document property "Delete movements" to the state "Do not delete movements automatically" ...: the interactive process stops action "Cancel execution" (becomes inactive in the context menu) - Which group of configuration objects does the "Interfaces" object belong to? documents - Changing the boundaries of calculated balances for the corresponding accumulation registers is carried out ... at the discretion of the user + When defining the directory in the configurator, it was indicated that it can be edited “in both ways”. Can a user, working with a certain list form, change the editing method (from “in the list” to “in the dialog”)? : can, using the button located in the command panel of the directory control + The information register can act as a registrar: any object - The directory can be subordinated to: several directories and plans of types of characteristics + When you try to write to the information register "Records" with measurement values, a combination of which is already registered in the register... the record is replaced - Is it possible to change the set of properties of a configuration object? For each configuration object, a set of properties is strictly defined by the program and cannot be changed. However, at the configuration stage, you can set specific values ​​for each of the properties, determining its behavior in 1C:Enterprise+ mode. The key can be of any type: for the structure - Which of the main properties of the configuration object allows you to present the name of the object in 1C:Enterprise windows in a readable form ( using spaces)? synonym+

p.(pzegt(papa time(K, h))

Inserts the value h into the object n in the position, enclosed by the key 1c.

If there already exists an additional value corresponding to the 1c key, then it does not change. Returns an object of type pacifier::stagman, boo1>, the first component of which indicates the element with the given key, and the second component indicates whether a new element has been inserted. Please note that by first waltz pa1 r generates an object of type pa(r sk, h", which is converted by the function zpzegt into an object of type r

p.uzpb(1s)

Returns a pterator that references the element (if one exists) specified with the key 1c. If such an element does not exist, returns the value p.epbO Generates an object tin times r, which will measure the key and the value with which this yupoch is brought, in the position designated by the operator those. Thus, the element te->G(gt) is of type sompt k and prglstvyayetsya key, and the element te->yesopb is of type y and prglstvoet the value corresponding to this key

B.Z. Algorithms

The student library includes many generalized algorithms that are written to use iterators; In this way, algorithms become independent of the specific data structures they work with and the types of their members. Note that associative containers have iterators that refer to composite types such as the class pa(r). Blindly, using these algorithms with associative containers requires careful design.

Most algorithms focus on sequences delimited by a pair of iterators, with the first iterator pointing to the first element, and the second to the memory region located after the last element of this sequence. Except where otherwise noted, all algorithms are defined in the header.

Includes statements about general algorithms

asppp1ate(b, e, t)

asppp1ate(b, e, t, d)

Defined in the title. Creates a temporary object o1y of the same type and with the same value as the object m. For ka:kaoto vhoanopz iterator te in the range (b, e) calculates ada" = abu + *tm or abu" = G(ab)", *3), depending on the form of the associate function that was called. The result is a copy of the abou object. Note that since the "+" operator can be overloaded, even the first form of the associate function can operate on types other than the built-in ones arithmetic type For example, we can use the algorithm asppp1ate two to concatenate all the strings in the copyer

B.Z. Algorithms

b(na~y zeugsp(b, e, c)

Returns a value of type boo1 indicating whether the value c belongs to the (sorted) field bounded by the unidirectional iterators b and e

copy(b, e, b)

Copies the values ​​of the sequence specified by the input iterators b and e into a receiving area called the basic iterator d. When executing this function, it is assumed that the destination has enough memory space to store the copied values ​​twice. Returns a value that represents the value of last elements receiver

erpv1(b, e, b2)

erpv1(b, e, b2, p)

A value of type bаo1 is raised, indicating whether the elements of the sequence specified by the input itertars b and e are equal to the elements of the sequence of the same size, the beginning of which is specified by the input iterar b2. To check, use the predicate p or the "=" operator if the predicate p is not specified

H 11(b, e, c)

Sets the elements of the paslepoeticity specified by the dog iterators b and e equal to the value of c. Returns the value of r(nb(b, e, c)

r(n0(r(b, e, p)

Returns an iterator indicating the first occurrence of the value c, or an iterar indicating the element for which the previcate p (if one is given) is true, in the sequence specified by the iterators b and e. Returns the value e if that element does not exist

1ex(codgvrsh s1 conprvge(b, e, b2, e2)

1ex(codgvrp(cv1 conprvge(b, e, b2, e2, p)

Returns a value of type LOO1 indicating whether the sequence of elements in the range [b, e) is less than the sequence of elements in the range [b2, e2). To compare elements, use the prelicate p or the operator "

pvc(s1, s2)

Returns the greater (two pvx functions) or the lesser (two bpp functions) of the values ​​specified by the arguments c1 and c2 that have the largest (smallest) ) an element in the assignment defined by the Unidirectional Igeragoras b not

Appendix B: Standard Library (At a Glance)

Defaults, restrictions and rules - These are optional attributes that can be defined across database columns and tables. U silence(default values) - these are the values ​​that are entered in a specific column. Restrictions Constraints are used as a way to identify valid values ​​for a column (to reject invalid values) and as a means of ensuring data integrity within and between database tables. linked tables. A constraint on only one column is called a value (column) constraint: it limits the values ​​of only that column. A constraint that affects multiple columns is called a reference constraint: in this case, a combination of the values ​​for the columns specified in this limitation, must meet the requirements of this limitation. There are five types of constraints: NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY and CHECK.

Null value(null value) is an unknown value for which the NULL notation is used . A null value in a column usually means that there is no data for that row in that column because the value is unknown, has no meaning, is not set, or will be set in the future. Null values ​​are not empty values ​​or the number 0; their actual values ​​are unknown, so no two null values ​​are equal.

IDENTITY property. When you create a table, you can define one of the columns as an identity column by adding the IDENTITY property to the column definition. If a column is created with the IDENTITY property, then SQL Server automatically generates a row value for this column, calculated from the initial value and the increment value. The seed value is the identity value for the first row inserted into the table. Increment is the amount by which SQL Server increases the identification value for sequentially entered rows. Each time a row is entered, SQL Server assigns the current identity value to the data item in the identity column that is entered in the new row. The next row entered will receive an identification value greater than the current maximum identification value by an increment. Identifier columns are typically used in primary key constraints in tables to allow rows to be uniquely identified. For example, if you specify IDENTITY(1, 10), then the value of the identification column for the first row entered will be 1, for the second row it will be 10, for the third row it will be 20, etc. If the initial value or increment is not specified, they will have default values ​​of 1 and 1. Identity columns cannot contain default values ​​and are not allowed to have null values. Each table can have only one identifying column.


By default, direct entry of data into identification columns is not possible and they cannot be changed. If you want to re-enter a deleted string and want to retain the old identifying value of that string, then you can override the default settings by using a statement like this:

SET IDENTITY INSERT table.name ON

Using this operator, you can insert a row and assign the value of the identifying column you need. Having finished entering a line, you need to disable the ability to insert into the identifying column using the following operator:

SET IDENTITYINSERT table_name OFF

After this, SQL Server will take the largest value from this column as the initial value used when adding subsequent rows.

Creating a default for a column using the CREATE TABLE statement is preferred, standard method. The following statement creates a table in the MyDB database containing defaults for both columnA (of type char) and columnB (of type int):

CREATE TABLE MyTable

(columnA char(15) NULL DEFAULT "pcs",

columnB int NULL DEFAULT 0)

The default value of "pcs" for columnA is compatible with that column's char data type, and the default value of 0 for columnB is compatible with that column's data type. If when inserting new line If a specific value for one or both columns is not specified in the table, the corresponding default value is used. Therefore, the only way to assign NULL to these columns is to explicitly insert NULL. Null values ​​are allowed because both columns have the NULL attribute specified. If columns were defined as NOT NULL, then you could not explicitly insert a NULL value.

PRIMARY KEY constraint used to specify a table's primary key, which is a column or set of columns that uniquely identifies a row in the table. Because the primary key identifies a row, the corresponding column never contains a NULL value. If you define a PRIMARY KEY constraint on a set of columns, the constraint specifies that the combination of values ​​for those columns must be unique for each row. The PRIMARY KEY constraint does not allow duplicate values. If a PRIMARY KEY constraint is assigned to a column or set of columns, a unique index is automatically created on that primary key column or columns. A table can only have one PRIMARY KEY constraint. A column with the IDENTITY attribute is a good choice for a primary key. Next T-SQL operator represents one way to specify the SSN column as the primary key when you define a table.

CREATE TABLE customer

midinit char(1) NULL,

last_name char(20) NOT NULL,

Cust_phone char(10) NULL)

Using alternative way, you can give a name to this constraint by adding keyword CONSTRAINT. To assign the name PK_SSN to your PRIMARY KEY constraint, use the following statement:

CREATE TABLE customer

(first_name char(20) NOT NULL,

midinit char(1) NULL,

last_name char(20) NOT NULL,

SSN char(11) CONSTRAINT PK_SSN PRIMARY KEY,

cust_phone char(10) NULL)

You can also specify a PRIMARY KEY constraint after all table columns have been defined. When using this syntax, the column name must be enclosed in parentheses and specified after the CONSTRAINT clause, as shown in the following statement:

CREATE TABLE customer

(first_name char(20) NOT NULL,

midinit char(1) NULL,

last_name char(20) NOT NULL,

cust_phone char(10) NULL,

CONSTRAINT PK_SSN PRIMARY KEY (SSN))

UNIQUE constraint ensures that no duplicate values ​​are allowed in a column or set of columns; in other words, the uniqueness of the values ​​in this column or set of columns is ensured. To support this uniqueness, SQL Server creates, by default, a unique index on the column or columns specified in the UNIQUE constraint. A UNIQUE constraint can be used on any column that is not part of a PRIMARY KEY constraint. A UNIQUE constraint can be used on columns that allow null values, while PRIMARY KEY constraints cannot be used on such columns. A column with a UNIQUE constraint can be referenced by a FOREIGN KEY constraint. You can define multiple UNIQUE constraints on a single table, as long as the total number of indexes on that table does not exceed 250 indexes.

To create a UNIQUE constraint on a table using T-SQL, use the CREATE TABLE statement. For example, the following statement creates a customer table with a UNIQUE constraint on the SSN column as an index:

CREATE TABLE customer

(first_name char(20) NOT NULL,

midinit char(1) NULL,

last_name char(20) NOT NULL,

SSN char(11) NOT NULL UNIQUE CLUSTERED,

cust_phone char(10) NULL)

CHECK constraint used to limit the set of values ​​allowed for a column certain values. Values ​​that are used when inserting into a column or updating a column are checked against the truth (value TRUE) of the Boolean search condition specified in the constraint. For example, if we needed to limit the range of possible values ​​allowed for the price column of the items table to values ​​from $0.01 to $500.00, we would use the following statement:

CREATE TABLE items

(itemname char(15) NOT NULL,

itemid smallint NOT NULL IDENTITY (1,1),

price smallmoney NULL,

item_desc varchar(30) NOT NULL DEFAULT "none",

CONSTRAINT PK_ itemid PRIMARY KEY (itemid),

CONSTRAINT CK_price CHECK (price >=0.01 AND price<= 500.00))

Creating and Modifying Constraints Using Management Studio

To create a table, expand the server folder and the database folder in the left pane of Management Studio, right-click the Tables folder, and then select New Table from the context menu. To display the Design Table window for an existing table, first click on the Tables folder, right-click on the table's name in the right pane, and then select Design Table from the context menu.

To indicate whether you can or cannot use null values in any column, simply check or clear the corresponding checkbox in the Allow Nulls column of the Design Table window. You can set this parameter when creating a table or when modifying it.

To create or modify UNIQUE constraint using Management Studio, follow these steps:

1. In the Design Table window toolbar, click the Indexes/Keys button.

  1. The following window will appear allowing you to create, edit and delete constraints associated with primary and unique keys

Select the names of the columns you want to include in the constraint and define properties for it.

You can ask PRIMARY KEY constraint one column or several columns. This column or columns must uniquely identify each row in the table. To set a PRIMARY KEY constraint, follow these steps:

  1. In the Design Table window, select a column by clicking one of the cells in its row. (You can select multiple columns by holding down the Ctrl key and clicking the gray cells to the left of the column names.)

  1. Right-click one of the selected columns and select Set Primary Key from the context menu. An image of a small key will appear to the left of the columns you set for the primary key.
  2. If you need to move a PRIMARY KEY constraint to another column, simply set that new column to be the primary key. You are not required to explicitly delete the original primary key first - SQL Server will drop and recreate the PRIMARY KEY index for you. You can also modify the PRIMARY KEY index in the Properties window. Your changes will take effect once you save your work by clicking the Save button in the toolbar.

To create CHECK constraint using the Design Table window, open that window for the table you want to work with and follow these steps.

1. Right-click the Design Table window and select Properties from the context menu to display the Properties window. Click the Check Constraints tab and click the New button for the table.

3. Notice the three checkboxes at the bottom of this window. Checking the Check existing data on creation checkbox means that existing table data will be checked against the CHECK constraint and if it does not match, the constraint will not be created. Checking the Enforce constraint for replication checkbox means that this constraint will be checked when data is replicated. Checking the Enforce constraint for INSERTS and UPDATEs checkbox simply means that the CHECK constraint will be enabled. If you do not check this box, then this restriction will be created, but it will not be activated, i.e. will have no effect.

4. Click the Close button and then click the Save button to save the new constraint. To modify a CHECK constraint, use the Check Constraint tab to change the Constraint name, Constraint expression, and check boxes.

You can also use the Check Constraints tab to delete a CHECK constraint by selecting the name of the constraint you want to delete from the Selected Constraint list and clicking the Delete button.

Laboratory work is designed for 3 hours of classroom training and consists of studying theoretical material and gaining practical skills in defining database tables, creating rules, restrictions, defaults, custom data types, indexes. Passing the laboratory work consists of answering test questions and demonstrating an individual task on a PC.

  1. Title and purpose of the work
  2. Individual task
  3. Scripts for creating a custom data type and database tables, in accordance with an individual task

Control questions

  1. List of supported data types?
  2. Custom data type. Purpose and methods of creation?
  3. Ways to define tables?
  4. Purpose of defaults, rules and restrictions?
  5. List of supported defaults, restrictions, rules?
  6. Methods for assigning defaults, restrictions, rules
  7. What are Null values?
  8. IDENTITY column property?

What is this article about?

This article continues the series of articles “First steps in 1C development.” It covers principles of working with universal collections. After reading the article, you will learn:

  • What are universal collections, and when and in what cases should they be used?
  • What do all universal collections have in common? What techniques can you use to work with all of them?
  • What is an array, how and when to use it? What methods does he have?
  • Why use a structure? How is it different from an array?
  • When should you use a list of values? How to display it on the form?
  • Compliance – what is it and when to use it? What are the advantages regarding structure?
  • What is the value table used for? How to describe its structure? How to add/remove lines? How to display it on the form?
  • Tree of values ​​- what is it used for? How to fill out and display the form? How to work with it?

Applicability

The article discusses the 1C:Enterprise 8.3 platform of the current edition.

How to work with universal collections in 1C

A collection of values ​​is a container that can usually contain any number of elements. However, there are often no strict restrictions on the data type.

You can add values ​​to a generic collection. All values ​​in the collection can be traversed. These collections are used mainly for some kind of processing in algorithms. Those. These are some dynamic structures that exist while the algorithm is running.

It is important to understand that collections are not stored in a database (we are not talking about the Value Store data type, which can store almost any type of data).

There are different types of universal collections: Array, Structure, Match, Fixed Array, Value Table, Table Part, etc. But all collections have similar behavior.

A collection can be created as a result of the operation of a function (the function returns a universal collection as a value).

You can obtain a new collection manually by calling the constructor and creating an instance of the class.

For example: OurArray = New Array;

The constructors for many generic collections are parameterized.

So, in the constructor for You can specify the number of members in the corresponding dimensions. Those. you can immediately declare multidimensional .

The corresponding description of the constructor is in the syntax assistant.

Thus, using constructor parameters, you can immediately set the desired behavior of a given object.

But the parameters are optional; the developer can not set them and further define the behavior of the Array as he sees fit.

Almost any universal collection can be created using a constructor (the exception is table parts, which act as configuration objects).

For universal collections, there are common concepts such as index and number. Each element of the collection has an index. In this case, the index starts from zero.

To access an element OurArray, you can use index access; for this, the index is indicated in square brackets.

For example, OurArray. Please note that in this case the system returns the Array element with index 3, and in order this is the fourth element of the Array.

For some collections there is also the concept of a line number. The line number starts with one. For example, for the tabular part there is such a property as row number. It is important to keep in mind that if we know the line number and want to access it by index, then we should use a value one less than the line number as the index.

The concept of a line number does not exist in all collections, but mainly in those that can be displayed in the user interface.

All collections use collection element traversal. Bypass is possible in two ways: cycle For And cycle For each of.

The methods that apply to most generic collections are Count, Index, Add, Insert, Delete, and Find.

Count is a function that returns the number of elements in a collection. It can be used before a cycle For, as shown in the figure.

The Index method does not exist for all collections, but only for those whose elements can be referenced. An example is Table of Values.

Table of Values– this is a specific collection of rows; rows can contain different columns with different types of values.

Each line represents an independent entity. You can get a link to it; through this line you can access the values ​​of the columns in this line.

The Index method allows you to determine which index corresponds to a given row (that is, the current position of the row in the table). Index values ​​start at zero.

Almost any universal collection has methods for adding new values ​​to a given collection. The figure shows how to fill an Array with values ​​from 0 to 10 in two ways.

To add an element to the Array we can use the method Add, indicate the value to be added in brackets. In this case, the value will be added to the end of the list, i.e. The array will constantly increase due to the last position.

Another method that allows you to add values ​​to a collection is the Insert. It is different from the method Add in that you can specify where to insert the added element.

Syntax: Insert (,)

The first parameter specifies the index into which the new value will be inserted. Those. for example, we can specify that each value should be inserted at the beginning of the list (second method in the figure above).

To remove elements from a collection, use the method Delete. The Delete method specifies by index which element we will delete.

Syntax: Delete()
Usage example: OurArray.Delete(5);

It should be noted that for those collections where strings represent an independent entity (for example, for Tables of Values), we can also use the method of getting the index in order to later delete this row.

Almost all collections have a method for searching for a value - Find. The value we want to find is passed to the method. Some collections allow you to set some restrictions.

For example, in Value Table you can specify the rows and columns in which you want to search.

If the value is found, this method returns the index or the specified string. If the value is not found, a value of type is returned Undefined. In relation to an Array, returns Index, or value Undefined.

Usage example: OurVariable = OurArray.Find(8);

Universal collections can be cleared very quickly, i.e. remove absolutely all elements. For this purpose the method is used Clear(), which removes Array elements, rows Tables of Values, or data from other collections.

Additional methods for Array

Method BBorder() returns the number of elements minus one. Those. if we use a loop For, then instead of the Quantity method we can immediately use the method Border().

In particular, the variable QuantityInArray could be defined differently:

QuantityInArray = OurArray.InBorder();
Then, when describing the cycle itself, one should not be subtracted from this variable.

The Set method allows you to assign a value to an Array element by index.

Syntax: Install(,)

Example: OurArray.Set(2,8);

Alternative option: OurArray = 8;

You can use the method for an Array Get, for reading a value at an index without resorting to using square brackets.

Syntax: Get()

Example: OurVariable = OurArray.Get(2);

Alternative option: OurVariable = OurArray;

Universal collection Structure

A Structure, like an Array, can have an unlimited number of elements, but the content of the element differs from the Array.

The structure is a collection, each value of which consists of a pair. The first element of the pair is called Key. The second element of the pair is Meaning.

Key is a strictly string data type that describes a value. For example, To the key"Code" can correspond to the value 113; To the key“Name” meaning “Vasya”. The Value itself is not subject to a data type restriction.

The structure is very convenient to use if we want to create a certain list of parameters. If this Structure called OurStructure, then we will refer to its two values ​​as follows: OurStructure.Code and OurStructure.Name.

This kind of access is much more convenient than if we defined all the parameters in an Array and accessed them by index.

Structure makes program code readable (understandable). Structure is used quite often, much more often than Array.

It is used to describe certain parameters, of which there are often quite a large number in all algorithms.

In addition, the Structure is used if the procedure and function contain a large number of passed parameters.

Then it is much more convenient to write all the parameters into the Structure and pass it on. Those. the parameters of procedures and functions are “packed”.

Separately, it should be noted that as Key Not absolutely any line can appear in the Structure. Certain restrictions apply.

Key should act as an identifier. This means that in Klyuche there must be no spaces and it cannot start with a number.

Acceptable start Key with a letter or underscore. Thus, Key must satisfy the requirements for creating identifiers.

Let us note how else a Structure differs from an Array. There is a method in the Structure Insert, there are two methods for insertion in Array: Insert(to a certain position) and Add(to the end of the list). In an Array, all elements are ordered.

Structure is a kind of disordered set. This is why there is only an insert method for a Structure.

The value is inserted not at a specific position, but into the specified set. A Structure cannot be accessed by index, like other generic collections.

Structure elements are accessed only by Key name. However, the For Each loop also works for the Structure, but you should not rely on the order of the Structure elements.

A structure is created in the same way as other generic collections by using the New constructor, specifying the data type Structure.

Like an Array, a Structure's constructor can have parameters. Those. it is possible to describe the very content of a Structure using a constructor.

Unlike an Array, where you can simply specify the number of elements for all dimensions, in a Structure you can specify the content itself.

For example: OurStructure = New Structure (“Code, Name”, 133, “Vasya”);

Separated by commas, the names of the Keys are first listed, and then, accordingly, in the same sequence, the values ​​of the parameters.

There is a method to add a new value to the Structure Insert, which inserts a new pair (Key and Value).

For example: OurStructure.Insert(“FamilyMembers”,3);

The Structure is characterized by another method that is used quite often. This is the method Property.

Using this method, you can understand whether there is an element in this Structure whose Key has such and such a name.

If such an element exists, the system will return the value True, otherwise – False.

For example, the expression OurStructure.Property (“Family Members”) will be equal to the value True. This method is used quite often when analyzing the Structure.

As with any universal collection, it is possible to access the properties of a Structure by index. But the index for the Structure is a string value.

For example: Report(OurStructure[“FamilyMembers”]);

However, we should not forget that a Structure is an unordered set of objects, which is why accessing by index 0, 1, 2 is unacceptable.

Generic collection List of values

ListValues is a linear list of elements of any data type.

Each element consists of several values. Schematically, a list of values ​​can be represented as a list with four columns.

First column - Mark. It has a Boolean data type and allows the user to either check or uncheck boxes.

The other column is a picture that can somehow visually represent this element, i.e. match this string with a picture.

The third column is the stored value itself, i.e. this is any type of data, and it can be different in different lines.

The fourth column is the presentation, i.e. this is a kind of string description of a given value. The view will be displayed to the user when he views this element. In this case, if the representation is not specified, the system will try to obtain representations for the element contained in this position.

ListValues– this is the object that the user can visually work with. Those. ListValues can be displayed on the form.

The user can perform some actions with it. Besides, ListValues can be inferred independently using methods, i.e. show on the screen in some branch of the algorithm (with the exception of server code) so that the user selects some line or checks some boxes.

We'll find ListValues in the sitax assistant. Constructor ListValues not parameterized (you cannot set any default values).

There are methods such as:

  • Insert(,) ;
  • Add(,);
  • Quantity();
  • Index().

There are also special methods, for example, UnloadValues(). This creates an Array into which the list of values ​​is copied. For example:

Array of Elements = List of PriceTypes.OutloadValues();

There is also a reverse method:
ListPriceTypes.LoadValues(ArrayItems);

There are search methods:
FindByValue(); FindByIdentifier().

There is a copy method:
ListCopy = PriceTypeList.Copy();
This method is intended to make some kind of modification to the copy.

There are methods:
SortByValue();
SortByView().

Methods SelectItem(,) And MarkItems() call a modal dialog box that stops execution of the algorithm until the user closes the window.

To use these methods in configuration properties Mode of using modality must be set to Use.

Example code called from a Managed Application module:

Display this code in user mode (modal dialog).

Below ListValues used as an available data type for form attributes. We create a new attribute for the processing form and define its type ListValues and display it on the form.

Creating a new team Fill inGifts, transfer it to the form and define an action handler for it.

In user mode, when you click the Fill in Gifts button in the processing form, a completed list will appear.

If desired, the list can be edited: some elements can be added, some can be removed.

Versatile Collection Compliance

This collection is very similar to Structure. Just like Structure, Mappings are sets of values ​​that consist of a key and the value itself.

The main difference is that any data type can be specified as the Key, as well as for the value. In view of this feature, it is necessary to access the match value by index; the key value is indicated as the index value.

The key can be a data type other than a string. The properties and methods of working with Compliance are almost the same as those of Structure.

The Compliance Constructor, unlike the Structure, does not contain the ability to specify parameters.

Usage example:

Correspondence is convenient to use when you need to connect any two structures. For example, each row in the tabular section must be matched with a row from the table of values.
In this case, the table section row is used as the Match key and the corresponding value is indicated.

When inserting elements into a collection Match in addition to the method Insert(,) Another way to insert a value is to use the regular assignment operator.

For example: OurMatch = NewMatch;
Match = 999;

Those. if an element was not present in the collection, then it will be added using the assignment operator, and if it was present, it will be updated.

This is in contrast to Structure.

Universal Collection Table of Values

Table of Values is a table with an arbitrary number of rows and an arbitrary number of columns. The intersection can store values ​​of any data type. If necessary, columns can be typed, i.e., you can determine in which column what type of data is stored.

You can leave the columns untyped, then values ​​of different types can be stored in one column in different rows.

Differences Tables of Values from a two-dimensional Array:

  • this is an object that the user can work with (the table of values ​​can be displayed on the screen, the user can fill it out, and the entered data can then be read);
  • building indexes for quick search;
  • cloning, filling an entire column with a certain value, uploading all columns to an array.

Table of Values used as a kind of information storage buffer. Table of Values is returned and accepted as a parameter by many system methods. It is possible to build a query against the Table of Values.

So, Table of Values consists of a set of rows and a set of columns. Both rows and columns are collections.

Those. inside the collection Table of Values there are two more collections. Let's turn to the syntax assistant and find Table of Values.

Supported data types: itself Table of Values, which consists of strings. Each row is represented by a data type RowTableValues, which has its own properties and its own methods. Available Collection of Table ColumnsValues also has certain properties.

Important point! The procedure that creates Table of Values, must compile &OnServer.

Before you start working with Table of Values, you need to determine what columns it will contain (i.e. create them). Syntax:

Add(,)
(optional)
Type: String.
(optional)
Type: DescriptionTypes
(optional)
Type: String.
(optional)
Type: Number.

For example:

To call this procedure we will use the command.

In description Tables of Values the elements of the collection are precisely RowsTableValues.

Unlike columns, which consist only of properties (Name, Type, Heading, Width), in RowTableValues There are both properties (access by column name) and methods (you can get and set a value, work with owners).

To add a new row to the table you need to use the method either Add(), or Insert(). In the second case, you should indicate at what position the required line should be placed.

To assign a value to a column, we use a dot to access the column name or index (using square brackets).

For filling Tables of Values The following methods can be used:

Clear()– to remove all rows from Tables of Values.

FillValues(,)– allows you to fill all columns or selected columns with one value.
LoadColumn(,)– loads a column from the array.
UnloadColumn()– unloads the column into an array.

The last two methods are convenient to use when you need to transfer a column from one value table to another.

Copy(,)– allows you to create a new one based on an existing table Table of Values, and not all rows and all columns, but only some of them. Return value – Table of Values.

You can copy the structure Tables of Values. There is a corresponding method for this CopyColumns(). We'll get an empty one Table of Values with the required structure.

IN Value Table there is a method Total(). You can specify the column in which you want to sum the numerical values. In relation to the previously shown code in the Tableau, you can calculate the value: TK.Total (“Amount”).

IN Value Table it is possible to group (collapse) numerical values ​​by identical values ​​of certain columns using the method Collapse(,).

In relation to the previously shown code in the Tableau, you can calculate the value: TK.Collapse(“Day of the Week”, “Amount”).

Table of Values can be shown on the user screen so that you can perform any actions with it. But unlike ListValues You can’t just call up a table on the screen from program code.

To display Table of Values on the screen, create a form attribute and assign a data type to it Table of Values.

After that, the resulting table should be displayed on the form.

In the form module at the end of the previously compiled algorithm (in the Procedure for Creating a Value Table), you should add:
ValueInFormData(TK, Table);

Universal collection Tree of values

a universal collection that is very similar to Table of Values. The difference from a table is that the rows of the tree can be subordinate to each other, i.e. some kind of hierarchy may be formed.

This can also be reflected on the screen. A value tree explicitly consists of a collection of rows and a collection of columns. There are two properties in the tree: Rows and Columns.

Since rows can be subordinate to each other, each row can have a Parent, as well as its subordinate rows.

Let's create the corresponding Tree command and its processing procedure.

Let's create in which there is one parent row and two subordinate rows.

Let's create the form attributes DerZn(data type – Value Tree).

For this attribute, we will create the Year and Month columns.

Move the corresponding element DerZn on the form.

At the end Procedures TreeOnServer() let's add:

ValueInFormData(TreeZn, DerZn);

Let's check what happened in user mode.

Using a button Add you can add new lines. They can also form a hierarchy.

To traverse all the elements of the value tree, we will need to use recursion, i.e. calling a procedure from itself. For example, processing a value tree might look like this:

This concludes our first acquaintance with universal collections.

In the next article we will look at what important mechanism a developer can use to simplify access to a directory element from program code.