MsgLoopHandler: an event driven wrapper for the Dopus message loop as include script

Yep, I learned that quite recently. In javascript (and JScript) :
var myVariable = whatever : local scope (current function or file it declared out of a function).
myVariable = whatever : global scope. Meaning current function and out this function too if the code is somewhat accessible/included. In that case, it can clash with some code using the same variable name. I think that if you declare var myVariable after just myVariable, it pops an error at exec time.

@Felix.Froemel : your last modification to take into account @MartO request for handling arrays of controls to be passed on seems to have broken it for me.

I've put some more logs to try and understand because, even if I call AddEventHandler about 32 times (really :slight_smile: ). At startup, it displays only 2 registered Event Handlers and without any further description.

The problem seems to come from the test you added about the type of eventSenderName in AddEventHandler.
The problem is that I provide a string ... which is not instanceof String.
This seems to be another trick of javascript (see javascript - How is typeof string not an instanceof String? - Stack Overflow).

As per suggested in this SO post, I tried and replace the instanceof String by typeof eventSenderName === "string"), and it now works much better (37 event handlers end up registered and the list display looks ok as the first clicks I tried).
I will need more testing tomorrow (2am here ... I have to go to sleep :slight_smile: )

Yes, @Felix.Froemel, I can confirm that handlers fail to register with string literals.

And I'm amazed this didn't happen on my side yet, but that's only because, by complete coincidence, I have only used arrays and one actual String object as the parameter since version 2.3. And I have to admit I didn't try all the out-commented tests in the test function.

Luckily it's a simple fix...

Fixed in v2.32. Thanks for letting me know. I thought I tested it and it worked ... :man_shrugging:t2:

1 Like

Thanks. As per the SO post, I think it works if you use var myString = new String(); but does not if you use string literals.