Evaluator If clauses within For Loops

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 was this thread asking for a Null coalescing operator.

I am kind of able to isolate the problem I have found, but in other attempts I have made to isolate it I have failed !

Here's my simple attempt to isolate the problem:

But when I use the Ternary Operator it works !

But this result isn't always the case !
I have been able to use If clauses within For Loops !
I still have not isolated this problem.
Am I doing something wrong ?

This started with this.

But the Ternary Operator works.

YEAH !
Am I missing the obvious ?
Good Night.

The error's coming from line 12, not the if statement.

name == newname ? break : Output(newname); looks a bit weird, not sure if that will work properly or not.

What happens if you change that to if (name == newname) { break; } ?

Thanks for reading Jon !
Sorry, but ....

Same error with the simple version.

Are you missing a semicolon at the end of your if statement (line 9)?

Ok, got it. Fixed in the next update. Thanks for the report.

PS: It makes it easier to test evaluator/script problems if you provide the code in text form rather than a screenshot :wink:

@lxp
It is if(!x) { x = y; } which is the same as

if(!x)
   {
   x = y;
   }

But yes, I also wondered if a semicolon at the end of line 9 would help.
I tried it. It didn't make anything worse, but it didn't fix it either.

@Jon
Thanks very much.
It helps to know someone else gets the same result.

Sorry for not uploading the text.
Here they are if anyone wants to try them.
For Loops - If and Break.zip (831 Bytes)

Thankyou !

Note: This general thought helps me think out some regular expressions that need to be repeated multiple times without thoughtlessly causing an infinite loop.

From the manual:

When used with the Rename command only, the old name pattern can be followed with a # character to indicate that the search and replace operation should be repeated multiple times