lxp
October 29, 2025, 4:54pm
1
This works fine on its own:
if (1 == 2) {
Output("if");
}
else {
Output("else");
}
Running it inside a loop ends with a syntax error:
For
for (i = 0; i < 5; i++) {
if (1 == 2) {
Output("if");
}
else {
Output("else");
}
}
While
i = 0;
while (i < 5) {
if (1 == 2) {
Output("if");
}
else {
Output("else");
}
i++;
}
Similar to
I am very confused here.
This topic is the result of some fun tinkering I have done after two other recent threads.
What got this started was a discussion of regular expressions. It forced me to rethink some things. Thankyou !
More recently there…
Jon
October 30, 2025, 6:16am
2
Thanks, fixed in the next update.
1 Like
The Evaluator does not replace the old scripting and commands. Rather, it is somewhere between the two and works in conjunction with them. It is less powerful than full-blown scripting, but also has lower overheads and is guaranteed not to get stuck in loops (since it has no loops!). This allows it to be used in places where calling a normal script could cause problems.
So there are loops in Evaluator though.
lxp
October 30, 2025, 4:33pm
4
Let's play with the While loop a bit more.
i = 0;
while (i < 5) {
Output("Hello");
i++;
}
We can enhance the output a bit:
We can check and increment the counter in one go:
But we can't do both:
The For loop behaves similarly, but the coding style is a bit awkward:
for (i = 0; i++ < 5;) {
Output("Hello");
}
Not on a computer to test: what about casting i as str in the Output statement?
lxp
October 30, 2025, 9:10pm
8
BTW, JScript is cool with this style.
var i;
for (i = 0; i++ < 5;) {
DOpus.Output("Hello " + i);
}
i = 0;
while (i++ < 5) {
DOpus.Output("Hello " + i);
}
Jon
October 31, 2025, 2:21am
9
Thanks, fixed in the next beta!
1 Like