General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion I wann to know whether xmetal support javascript for macro.

  • deepak

    I wann to know whether xmetal support javascript for macro.

    Participants 6
    Replies 7
    Last Activity 12 years, 1 month ago

    I want to write macro for “Hot keys” in java script, I want to know whether xmetal support javascript or not.

    How can i found any example of such macro written for xmetal.

    Thanks,
    Deepak

    Reply

    deepak

    Reply to: I wann to know whether xmetal support javascript for macro.

    I am trying to write an macro for “Copy previous tagged block”.

    Any one can help me on this.

    Thanks in advance.

    Reply

    Derek Read

    Reply to: I wann to know whether xmetal support javascript for macro.

    JScript is supported. Many people consider JScript, JavaScript and ECMAScript so similar they are virtually interchangeable (and for most purposes they practically are). So in that sense the answer you are looking for is probably 'yes'. However, it is not really the scripting language that is important for XMetaL Author, it is whether a scripting engine is available. A scripting engine is what actually executes the scripts you write.

    Both a JScript and VBScript engine are installed and available on Windows by default and both can be used with XMetaL Author. The advantage here is that no further software need be installed. Microsoft calls the software that manages engines (including JScript and VBScript but also including others) the “[url=http://msdn.microsoft.com/en-us/library/shzd7dy4(v=VS.85).aspx]Windows Script Host[/url]”. Other engines are available for other languages, but these must be installed separately as they do not come from Microsoft (Perl and Python are examples) and are provided by 3rd parties.

    For JScript and VBScript examples, you may wish to see XMetaL Developer. You will also need to know which APIs are available to call (about 1000+ APIs are provided to allow your scripts to control many aspects of XMetaL Author) and these are documented in the Programmers Guide that comes with XMetaL Developer. XMetaL Author itself includes many script examples, which are organized into files with a *.mcr file extension. You can also [url=http://forums.XMetaL.com/index.php?action=search]search this forum[/url] for examples as there are quite a few here. However, you won't find them searching for “javascript”, search for “jscript”.

    Reply

    Derek Read

    Reply to: I wann to know whether xmetal support javascript for macro.

    So, having answered the question in your title (“is JavaScript supported”), I'm not sure how to answer your other questions. Can you explain in more detail? If you could describe what you mean by “previously tagged block” that would help a little bit. Also, what do you mean when you say “copy”? Do you mean “put it {the thing you want to copy} onto the Windows clipboard”? Or do you actually mean that you want to do both a copy and paste (ie: duplicate something)?

    Reply

    deepak

    Reply to: I wann to know whether xmetal support javascript for macro.

    Yes, I want copy & paste functionality. Actually I want to copy previous tag like (

  • ) with content and want to paste that one again
  • Reply

Derek Read

Reply to: I wann to know whether xmetal support javascript for macro.

You might try something like the following:

[code]//XMetaL Script Language JScript:
var rng = ActiveDocument.Range;
var elemName = “LI”;
if (rng.MoveToElement(elemName,false)) {
rng.SelectElement();
var prevElem = rng.Text;
Application.Alert(prevElem);
rng.FindInsertLocation(elemName);
rng.Select();
if (rng.CanPaste(prevElem)) {
rng.PasteString(prevElem);
}
else {
Application.Alert(“Unable to find a location to insert a new <" + elemName + ">.”);
}
}
else {
Application.Alert(“There is no previous <" + elemName + "> in this document.”);
}[/code]

This is just an example. There will be many other possible ways to write similar functionality. It also might not do exactly what you want, so you'll need to tweak it in that case.

You'll all want to build that into an MCR file for deployment with your DTD / XSD, or you could put it into an application level MCR file so that it is available to all schema, one that sits in the AuthorStartup folder. However, it seems like this is a schema-specific script (ie: not every document type is going to support

  • ). Deployment is discussed in XMetaL Developer in the Customization Guide.
  • Reply

    karthic2861

    Reply to: I wann to know whether xmetal support javascript for macro.

    I am new to Xmetal.  I want write javascript code for Copy/paste Clipboard function.

    Thanks in advance

    Reply

    Derek Read

    Reply to: I wann to know whether xmetal support javascript for macro.

    Obtain the XMetaL Developer Programmers Guide: http://na.justsystems.com/content-support-user-guides
    If you search for “clipboard” you will find lots of information.

    If you have specific questions about something please post (probably a new) topic on the forum or contact XMetaL Support.

    Reply

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

    Lost Your Password?

    Products
    Downloads
    Support