Pages: 1
Author Topic: script example: web service call from XMetaL Author script  (Read 4064 times)

Posts: 23

« on: November 12, 2009, 06:09:46 PM »

The 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.mcr

- 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.


* (0.77 KB - downloaded 316 times.)

Posts: 23

« Reply #1 on: November 16, 2009, 06:19:48 PM »

One 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"GET","",!ASYNC);
var time = xmlhttp.responseText;
Application.Alert( time );
//clean up
xmlhttp = null;
Pages: 1
Jump to: