Friday, 4 October 2013

Macros - Version

Before starting this post on the Version macro I would like to share with you a new page which I have added to the blog which will contain a consolidated list of the macros which I have built and published here. It is easily accessed from the Macros link on the menu bar above.

And the first macro to be released to that page is the Version macro:


This macro can be embedded into other macros to allow checking of the version against an XML file stored on the web.


What Does it Do?

I had the idea for this macro several years ago and actually presented it at the developer part of the Inspire conference in 2012.  But it never actually made it to this blog until now.

The idea behind the macro is that it allows other macros to be versioned and to check against a web page to see if there is a newer version available.  Now my initial plan was that this check would be done every time the macro that used it was run.  Unfortunately downloading the web page that contains the versioning information, while not terribly slow (a few seconds), is slow enough that I don't want to do it every time one of my macros is used.  I think this limitation is some of what stopped me posting this macro until now.

So in the released version of the macro I have come up with a compromise.  The macro is embedded in other macros as intended, but by default it does nothing. (All of its tools are disabled by a tool container).

Usage by End User

Here it is being used in the Dynamic Formula macro:

Then when a user wants to check that their macro is up to date they:

  1. Open the macro they want to check
  2. Click on the version macro
  3. Check the Check Box to enable checking (see screenshot right)
  4. Run the module.

They then get messages in the log which tells them if the macro is the latest version available:

or a message telling them I have released a new version:

Usage by Macro Developer

If you would like to use this in your own macros then feel free.  To set it up you just drop it into your macro, point it to an XML file you have hosted somewhere on the web and enter the version number to match the version number in your XML file.  The XML file needs to look like this:

You can copy the example here:\Example.xml

Then when you update your macro in the future, you just need to bump up the number in the version macro and in the XML file and include whatever message you would like to tell your users in your XML file.  Then anyone who has an old version of your macro and checks for updates will get your message.

How does it work?

The module is fairly simple

The two text inputs on the left get updated from each of the two questions in the macro and the tool container which contains the whole module gets enabled/disabled by an action which is fed by the check box.

From there:
  • A download tool grabs the XML from the web
  • We use an XML parse tool to digest the XML
  • A join tool brings in the version number from the parent macro
  • We then compare the versions and use a series of message tools to display the various messages to the end user.