XMetaL Tips and Tricks
XMetaL Community Forum › XMetaL Tips and Tricks › script example: web service call from XMetaL Author script
-
murray November 13, 2009 at 12:09 am
script example: web service call from XMetaL Author script
November 13, 2009 at 12:09 amParticipants 0Replies 1Last Activity 13 years, 2 months agoThe attached file contains an example of how to make a web service call from script in XMetaL Author. For example this could be used make a call to a server to get/put data when the user selects a menu item or clicks on a toolbar button.
Files in the zip:
– testWebService.mcrInstallation:
– copy the testWebService.mcr file to the Startup folder then launch XMetaL Author.From the comments in the mcr file:
// This macro illustrates how to make a web service call from
// script running in XMetaL Author. For example code like this could be
// invoked from a menu item or toolbar button in XMetaL Author.
//
// To run this code, put this file in the Startup directory in
// the XMetaL Author installation folder, start XMetaL Author,
// and go to Tools>Macros. In the macro list, select the macro
// named GetTimeFromWebService and then click on the Run button.
// An alert should be displayed that shows the time returned by
// the web service call.Thanks
Murraymurray November 17, 2009 at 12:19 am
Reply to: script example: web service call from XMetaL Author script
November 17, 2009 at 12:19 amOne of my collegues pointed out that I forgot to set the reference to xmlhttp to null at the end of the example code. Please note that any objects that are created using “new” in javascript should be set to null when they are no longer needed. Otherwise XMetaL Author may hang during exit such that the user interface closes but the XMetaL process remains in memory. This causes XMetaL Author to fail to launch until you open the Windows task manager and kill the xmetaL process.
So the code should look like this:
var ASYNCÂ = true;
var xmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);// this is the XMLHttpRequest object
xmlhttp.open(“GET”,”http://www.w3schools.com/Ajax/time.asp”,!ASYNC);
xmlhttp.send(null);
var time = xmlhttp.responseText;
Application.Alert( time );
//clean up
xmlhttp = null; -
AuthorPosts
- You must be logged in to reply to this topic.