General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › I wann to know whether xmetal support javascript for macro.
-
deepak May 11, 2010 at 5:16 am
I wann to know whether xmetal support javascript for macro.
May 11, 2010 at 5:16 amParticipants 6Replies 7Last Activity 12 years, 10 months agoI 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,
Deepakdeepak May 11, 2010 at 5:22 am
Reply to: I wann to know whether xmetal support javascript for macro.
May 11, 2010 at 5:22 amI am trying to write an macro for “Copy previous tagged block”.
Any one can help me on this.
Thanks in advance.
Derek Read May 11, 2010 at 7:01 am
Reply to: I wann to know whether xmetal support javascript for macro.
May 11, 2010 at 7:01 amJScript 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”.
Derek Read May 11, 2010 at 7:08 am
Reply to: I wann to know whether xmetal support javascript for macro.
May 11, 2010 at 7:08 amSo, 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)?
deepak May 11, 2010 at 8:49 am
Reply to: I wann to know whether xmetal support javascript for macro.
May 11, 2010 at 8:49 amYes, I want copy & paste functionality. Actually I want to copy previous tag like (
- ) with content and want to paste that one again
Derek Read May 11, 2010 at 5:47 pm
Reply to: I wann to know whether xmetal support javascript for macro.
May 11, 2010 at 5:47 pmYou 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.
karthic2861 March 30, 2012 at 12:45 pm
Reply to: I wann to know whether xmetal support javascript for macro.
March 30, 2012 at 12:45 pmI am new to Xmetal. I want write javascript code for Copy/paste Clipboard function.
Thanks in advance
Derek Read June 11, 2012 at 4:44 pm
Reply to: I wann to know whether xmetal support javascript for macro.
June 11, 2012 at 4:44 pmObtain 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.
-
AuthorPosts
- You must be logged in to reply to this topic.