FOR cycle

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

FOR cycle

Postby PetrS » 26 Sep 2014, 08:39

size=150For cycle extension/size
Version 0.1.75 and higher

For cycle was extended to be able iterate in increasing and decreasing cycle.

See attached example for more details.
Attachments
FOR.cls
(33.09 KiB) Downloaded 484 times
Ing. Petr Slepicka
DesignForms Online
Engineering calculations online - EuroCode, AISC, statics
Automate your static calculations today!

jkrsik
Posts: 30
Joined: 06 Oct 2014, 13:10

Re: FOR cycle

Postby jkrsik » 06 Jan 2016, 12:23

size=150FOR cycle improvements/size
Version P - 16.098.25+

New grammar for FOR cycle was implemented. It is based on url=https://msdn.microsoft.com/en-us/library/ch45axte.aspxC# grammar/url
code
//Example
r = 0;
FOR(i = 0; i < 10; i = i+2) {
TEXT(i);
r = r+i;
} /code
bSteps:/b
list=1
*Initial variable is established/*:m
*
list=a
*Condition i < 10 is evaluated/*:m
*If is less than 10, the condition evaluates to TRUE and body of FOR is executed/*:m
*The value i is incremented by 2/*:m
*The loop returns to the start of step 2 to evaluate condition again/*:m/list:o/*:m
*If condition is greater or equal to 10, the condition evaluates to FALSE and exit the loop /*:m
*Variable ends with value which return FALSE in the condition. i = 10/*:m/list:o

Every FOR statement defines initializer, condition and iterator.
codeFOR(initializer; condition; iterator){
body;
} /code

binitializer/b - define variable and its first value
bcondition/b - the condition for execution the FOR cycle. All type of conditions, including functions are allowed, icluding negative values
biterator/b - any type of iterators for increasing the initialized value are possible, including all C# operators - X++, X--... are possible

Examples:
codeFOR(i = 0; i < 5; i++) { }
FOR(i = 0; i < 5; i = i+2) { }
FOR(i = Pts.Count-1; i >= 0; i--) { }
FOR(i = Pts.Count-1; i >= 0; i = i-1) { } /code

Old grammar for FOR cycles still works, but is it not recommended for future use
codeFOR(i, 0, 9) {
TEXT(i);
} /code
See example:
attachment=0
FOR_new_grammar.cls
new FOR cycle grammar
(20.42 KiB) Downloaded 467 times
/attachment


Return to “Design forms features”

Who is online

Users browsing this forum: No registered users and 3 guests