Connect Mathcad to Internet Data Sources

One little-known feature of Mathcad 15 (and earlier versions) is the ability to connect to Internet data sources. Simply insert a scriptable component into a worksheet, define an input and an output, and insert this VBScript into the component code.

Function IEGetPage(URL)
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Navigate URL
  Do While IE.Busy
  IEGetPage = IE.Document.Body.outerText
 End Function

IEGetPage(URL) is a function that downloads the data the URL points to.

This function can be used to define the output of the scriptable component. For example, you could insert the following code into a push button event (PushBtnEvent_Exec)

Outputs(0).value = IEGetPage(Inputs(0).Value)

Outputs(0).value and Inputs(0).Value refer to the first input and output of the scriptable component. In this instance, the input would simply be a URL and the output would be the downloaded data.

So what can I do with this surprisingly cool functionality? Well, the US Geological Survey host constantly updated earthquake data on their website. This data gives the location (i.e. the latitude and longitude) and magnitude of earthquakes over a rolling time period, and can be downloaded as a text file. is a typical example.

This text file is updated several times a day with new earthquake data and can be downloaded straight into Mathcad using the VBScript given above.  Check out this Mathcad worksheet (the link is at the bottom of this post).

Once the data the data is in Mathcad, some parsing is needed to strip out headers and other unnecessary information.  You can then manipulate and analyse the filtered data.

In the Mathcad worksheet, I’ve plotted the location of earthquakes on a map of North America (the mapping data is low resolution, but it serves its purpose). Here’s what the plot looks like:

My next mini-project (should I get some time off from the salt mines) is to project this earthquake data onto a globe.

I’ve also connected Mathcad to other Internet data sources, including historical stock quotes and foreign exchange rates.

Mathcad Worksheet to Download Earthquake Data from the US Geological Survey Website

What do our Customers say about us?

“I am very satisfied with Origin. I think Origin is an excellent plotting tool. Its capabilities are vast, diverse, and beyond my needs. I appreciate the fact that almost anything on a plot can be adjusted according to a desired preference.”

Matthew D. Sena - Sandia National Laboratories

It was about as perfect as a teaching seminar could be. Moved at the correct pace and encompasses a good amount of information

I have now followed your (very clear!) instructions and am happy to report that my problem is solved. Magic! You have made me a much, much happier person!

CS, Reading, UK

Excellent – a natural teacher! Approachable and willing to help us individually

PD, Manchester, UK

For the time being we are unable to offer the following product ranges although we are currently working hard to increase the number of products we can offer in the future. Please contact us to talk about alternative products that we may be able to offer you.