while(!FolderEnum.complete) throws "A method was called unexpectedly"

Oh! Exactly, that was meant to go into the error check above.

Hmmm... changing the continue behavior to an else block doesn't change anything.

I tried a for loop with for (var fEnum = new Enumerator(contents); !fEnum.atEnd(); fEnum.moveNext() ) (and to be sure, also with var fEnum = new Enumerator(DOpus.FSUtil.ReadDir(folder)); ), as in this example, but that loop never executed its block. Just for completeness sake, how would I enumerate the collection with a for-loop?

But mainly: I found the cause of the issue:

I was checking whether the item was a directory with file.is_dir(), but it needs to be file.is_dir: the property is not a function. I got confused there.

the console was reporting all errors 2 lines off, because my script had its first meaningful declaration at line 3.
I noticed that something was wrong when I commented something out in favor of an alternative, and suddenly the error was reported to be in a line that contained only a comment.

When the script starts like this:

var a = "b"; //<-- meaningful line
// var b = "c";
var c = "d";

function OnClick(ClickData){
...

, the compiler(?) starts counting at line 1.
But, treacherously, when it starts like this:

// var a = "b"; //<-- not meaningful line
// var b = "c"; //<-- not meaningful line
var c = "d"; //<-- first meaningful line

function OnClick(ClickData){
...

, the compiler(?) starts counting at line 3.
That's why I thought the error was happening in the evaluation of .complete :man_facepalming:

If that's not desired behavior, it might need fixing. Otherwise: thank you as always for your time and patience, I got it working now :slight_smile: