Pages: 1
Print
Author Topic: How to use javascript timer function like setInterval  (Read 3480 times)
swisslex
Member

Posts: 2


« on: February 19, 2013, 04:04:45 AM »

Hi,
I try to set a interval to make some periodical checks.
I work with the Javascript enviroment of XMetaL.
Is there any similar available in XMetaL?
In Javascript it would look like this:
setInterval(function () { alert("Hello") }, 3000);

Thanks for your help.
Logged
Derek Read
Program Manager (XMetaL)
Administrator
Member

Posts: 2621



WWW
« Reply #1 on: February 19, 2013, 05:31:24 PM »

XMetaL Author does not implement an equivalent to the setInterval() method that most web browsers support (I assume that is where you got the idea).

Perhaps you could explain what you are creating in case I can think of an alternate solution. Knowing what you are building would also allow me to put in a feature request.

The closest I can get without using any 3rd party controls is XMetaL's GoToSleep() method. You might try putting that into a loop. However, that method is modal (stops the user from doing anything and displays an hourglass icon). I'm guessing that isn't what you are looking for.

Note: setInterval() isn't defined in JScript/JavaScript/ECMAScript, it is a method attached to the "window" object in IE (and most other browsers). I only note this because *if* Microsoft was to implement setInterval() in the JScript engine (probably the scripting engine your XMetaL macro is using to run) it would then be available to XMetaL Author. In theory you might try embedding the WebBrowserControl (ActiveX version of IE) into the Resource Manager or a document to use its version of setInterval(). This would be tricky as at least part of your code would be running in the browser and might need to call over to XMetaL instantiated as COM as well. If you chose VBScript instead of JScript then the issue would be similar as there is no equivalent in VBScript. Other scripting languages that can be used with XMetaL might have an equivalent method, such as PerlScript or Python. I don't use those much though so have not checked to see if they do.
Logged
swisslex
Member

Posts: 2


« Reply #2 on: February 20, 2013, 02:01:07 AM »

Thanks for your answer.
We use XMetal as external editor for our production tool. You have to acquire a lock for the document you want modify. This lock must be renewed periodically.
What I would like to have is kind of a timer / interval that triggers the lock renewal.
It would be nice to have something like this. But in my case there is a workaround. I will let the production tool renew the lock.
But the solution let XMetaL take care of that would have been a cleaner solution.
Logged
Pages: 1
Print
Jump to: