There are three inconsistencies with the repeat-until loop:
1) It does not allow the use of `begin` and `end`. That is odd, because:
-- The use of `begin` and `end` is mandatory for all other loops, and
-- `begin` and `end` mark a code block and these are commonly used in other programming languages when looping.
Code: Select all
x = 0;
repeat begin
Print("x = ", x);
x = x + 1;
end until x = 5;
Code: Select all
syntax error, unexpected 'until', expecting ';'
Suggestion:
Make the repeat-while loop accept the `begin` and `end` keywords optionally (!) so that this loop works consistently with the other loops.
-----------------
2) Using the parentheses (like we can do with the `while` loop) only causes the loop to run once, but the PowerLanguage Editor does not give an error when using parentheses.
Code: Select all
x = 0;
repeat
Print("x = ", x);
x = x + 1;
until (x = 5);
Without parentheses:
Code: Select all
x = 0;
repeat
Print("x = ", x);
x = x + 1;
until x = 5;
Code: Select all
x = 0.00
x = 1.00
x = 2.00
x = 3.00
x = 4.00
Suggestion:
If the repeat-while loop cannot work with parentheses, the editor should give an error to highlight this to the user. In the current situation, one can spend a lot of time debugging this situation because no error is triggered.
--------------
3) Oddly enough, in some situations parentheses are required to make the repeat-until loop run correctly.
This loop only runs once:
Code: Select all
x = 0;
repeat
Print("x = ", x);
x = x + 1;
until x < 5;
But if we add parentheses, it runs correctly:
Code: Select all
x = 0;
repeat
Print("x = ", x);
x = x + 1;
until (x < 5);
Code: Select all
x = 0.00
x = 1.00
x = 2.00
x = 3.00
x = 4.00
This is so inconsistent that I don't understand it. Is the rule of the undocumented repeat-until loop the following?
* "When the `until` condition uses the equal sign, parentheses should not be used because then the loop only runs once. But if you use a less than sign in the `until` condition, you should use parentheses because without them the loop only runs once."
To further add to the confusion, the
wiki example for the GetAppInfo keyword uses parentheses with the repeat-until loop, but the
FAQ does not.
-> MultiCharts Support, please address this last situation.
(Using MultiCharts64 Version 9.0 Release (Build 10014))