General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion How to identify XMAX versus XMEE in macros?

  • ghkrause

    How to identify XMAX versus XMEE in macros?

    Participants 1
    Replies 2
    Last Activity 13 years, 6 months ago

    In the beginning our JScripts were the same for the XMetL Enterprise Edition (XMEE) users and the XMAX users. Now this changes and I have to maintain two different sets of code. Would be a great help if there is a simple line of code to identify whether the code is executed in XMEE or XMAX environment.
    The programmer's guide did not show useful search results but maybe I tried the wrong search …

    Reply

    Derek Read

    Reply to: How to identify XMAX versus XMEE in macros?

    The ultimate solution for this would probably be for us to provide an equivalent to the Application.Skuname or Application.VersionNumber property from XMetaL Author in XMAX. Until that happens you can use something like this:

    [code]
    //XMetaL Script Language JScript:
    try {
    if (Application) {
    Application.Alert(“XMetaL Author”);
    }
    }
    catch(e) {
    ActiveDocument.Host.Alert(“XMAX”);
    }
    [/code]

    This code relies on the lack of the Application object in XMAX to uniquely identify it (and yes, I realize relying on an error being thrown is obviously not the best thing – but I cannot think of anything else that will work with current versions).

    If this is not acceptable then you may need to split your projects apart (until we implement a nicer solution or someone else can suggest something better).

    Reply

    Derek Read

    Reply to: How to identify XMAX versus XMEE in macros?

    Here is a more elegant solution that implements this in the form of a function you can reuse inside your own if...then statements or elsewhere (as in the example that follows the function):

    [code]// XMetaL Script Language JSCRIPT:
    function isXMAX()
    {
      try { if (Application) { return false; } } catch (e) { ; }
      return true;
    }

    if (isXMAX()) {
      // Hello XMAX
      ActiveDocument.Host.Alert(“XMAX”);
    } else {
      // Hello XMAU
      ActiveDocument.Host.Alert(“XMetaL Author”);
    }[/code]

    Reply

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

Lost Your Password?

Products
Downloads
Support