How to run multiple commands from a loop?

Suppose I want to create several folders. I could try using an evaluator loop like this:

=for (i = 1; i < 5; i++) {return "CreateFolder NAME=" + i}

However, this only executes the first iteration, creating just one folder. It seems there’s no way to continue the loop execution. Or am I missing something?

Alternatively, I could try accumulating the commands:

=cmd = ""; for (i = 1; i < 5; i++) {cmd += "CreateFolder NAME=" + i + CRLF}; Output(cmd); return cmd

This generates all the commands, but again, only the first line is executed. It appears there’s no way to run multiple commands from a single string.

Would it make sense to introduce a function such as Run() that could execute a string in the evaluator? Ideally, it could include a flag to specify the execution context (Opus, DOS, Windows, WSL, etc.).

1 Like

We've added something like this for the next beta. Thanks for the suggestion!

3 Likes