Logging Value Of A Variable In Monkeytalk Ide Javascript File
Solution 1:
Believe it or not*, but to date there is no way direct way to cause MonkeyTalk to log messages to the console. What you can do, however, is abuse a command like verifyNot
which will result in a log message. In a MonkeyTalk .mt this would be done like:
View* VerifyNot Message
I created the following helper script called log.js
for this purpose. Timestamps are automatically added by Eclipse, but not elsewhere so I have prepended the time.
load("libs/Executor.js");
functiongetTimeStamp() {
var now = newDate();
return now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds();
}
EXECUTOR.defineScript("Log", function(msg) {
this.app.view().verifyNot(getTimeStamp() + ": " + msg);
});
Finally, you don't need the executor boilerplate (only the verifyNot line), but we use that with scripts by Doba in order to be able to organize files in different directories (Doba.js renamed to Executor.js) -- another feature not available out of the box.
* It's almost like GorillaLogic doesn't want you to be able to resolve your own problems. ;)
Post a Comment for "Logging Value Of A Variable In Monkeytalk Ide Javascript File"