R
R
Roman Tarasov2017-03-20 11:29:29
1C
Roman Tarasov, 2017-03-20 11:29:29

Why does the For Each loop element remain initialized after the loop terminates?

Good afternoon!
There is a loop through the table of values:
For Each TekRow From the ItemsTable Loop
... ...
EndCycle;
Why, AFTER the loop terminates, does the TekRow variable remain initialized with the value of the last row of the original table of values? Platform glitch?
Version 1C: Enterprise 8.2 (8.2.19.130)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kinash, 2017-03-20
@raym0n

All right. This is the correct behavior since platform 8.0
. The loop is inside a procedure/function context. In the 1C language, unlike C ++, you cannot simply take and declare another isolated context with procedural brackets, the variables of which will be deleted when you go beyond its scope. All variables that are created within conditions and loops continue to exist and store the received values ​​until the end of the entire current executing procedure. If you need to conserve memory, then after your loop, you yourself need to take care of clearing the contents of already unnecessary service arrays and tables.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question