Page 1 of 1

FOR cycle

Posted: 26 Sep 2014, 08:39
by PetrS
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.

Re: FOR cycle

Posted: 06 Jan 2016, 12:23
by jkrsik
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 758 times
/attachment