FOREACH cycle

Info about design forms features
PetrS
Site Admin
Posts: 181
Joined: 11 Jul 2014, 13:55

FOREACH cycle

Postby PetrS » 17 Mar 2015, 10:15

size=150FOREACH cycle/size
Version: 13.400.25+

The FOREACH statement repeats block of instructions for each element in an array, list or collection. The foreach statement is used to iterate through the collection to get the information that you want, but can not be used to add or remove items from the source collection to avoid unpredictable side effects. If you need to add or remove items from the source collection, use a FOR loop.

The embedded statements continue to execute for each element in the array or collection. After the iteration has been completed for all the elements in the collection, control is transferred to the next statement following the FOREACH block.
At any point within the FOREACH block, you can break out of the loop by using the BREAK keyword, or step to the next iteration in the loop by using the CONTINUE keyword.


buSyntax:/u/b
code
FOREACH([Type] VariableExpression IN EnumerableCollection) {
Instructions
}
/code


buDescription of attached example:/u/b
There are two nested FOREACH cycles.
First loop iterate through all branches of stirrups. Second loop iterate through all points of that branch.
Note, that iterator variable "obBranch" is used as a source for second loop.
Attachments
Foreach.cls
(31.54 KiB) Downloaded 395 times
Ing. Petr Slepicka
DesignForms Online
Engineering calculations online - EuroCode, AISC, statics
Automate your static calculations today!

Return to “Design forms features”

Who is online

Users browsing this forum: No registered users and 4 guests