General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion How to use javascript timer function like setInterval

  • swisslex

    How to use javascript timer function like setInterval

    Participants 1
    Replies 2
    Last Activity 9 years, 11 months ago

    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.


    Derek Read

    Reply to: How to use javascript timer function like setInterval

    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.



    Reply to: How to use javascript timer function like setInterval

    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.


  • You must be logged in to reply to this topic.

Lost Your Password?