Written by Creo/Mathcad Guest Author
  • 2/6/2025
  • Read Time : 4 min.

Converting Your Advanced Controls Scripts to Mathcad Prime

Converting Advanced Controls From Mathcad 15 to Mathcad Prime

Editor’s Note: This blog is written by Orli Wolfson of the PTC Mathcad documentation team. She works on the Mathcad Prime Help Center. You may also watch a video version of this blog below.

With the introduction of advanced controls functionality in PTC Mathcad Prime, you may want to convert the scripts from your legacy Mathcad worksheets (such as from PTC Mathcad 15) to Mathcad Prime. In this blog post, read about how to do it, with some useful tips on the process.

Step 1: Use the Mathcad Converter

The Mathcad converter can convert advanced controls from legacy Mathcad to Mathcad Prime. Start by opening Mathcad Prime and using the converter.

A short reminder about converting legacy Mathcad worksheets to Mathcad Prime:

  1. In the Input/Output tab, Under the PTC Mathcad Worksheets group, select XMCD, MCD Converter.
  2. The PTC Mathcad Prime XMCD, MCD Converter opens. Add a worksheet that you want to convert and click Convert.

Watch this quick video for more information:


Step 2: Check the Conversion Log

Before proceeding, check the conversion log for any issues. Most conversion issues will also be listed as errors in the worksheet itself.

Step 3: Open the Converted Worksheet

After conversion, you'll receive a Mathcad Prime worksheet with converted controls. Sometimes, you may need to update the script to accommodate your specific workflows.

We recommend to recalculate or interact with each converted control after the conversion. To do this, make sure your Mathcad settings allow the recalculation of advanced controls and that the control is enabled.

Here are some common conversion issues you might encounter:

Changes in Radio Button Design

In Mathcad 15, radio buttons appeared as multiple buttons with a single selection.

In Mathcad Prime, they appear as a single control with multiple selections. An image is created in the Mathcad Prime worksheet to indicate the position of the radio buttons in the legacy worksheet. You can delete this image if you prefer. I find it useful to delete it and adjust the appearance to the way the new functionality works.

Here is how this radio button control looks before and after conversion. After deleting the extra radio button images, and resizing the control, it looks just like any other radio button:

Legacy Mathcad 15 radio button advanced control before and after conversion to PTC Mathcad Prime

Inactive Methods and Properties

Some methods and properties used in legacy Mathcad versions are inactive in Mathcad Prime. You can find a full list of inactive methods and properties in the PTC Mathcad Prime Migration Guide. All currently active properties and methods are listed in the Mathcad Prime Help Center.

When your legacy Mathcad scripts contain inactive properties or methods, they will appear as lines in the script after conversion. These lines do not work, but they also do not cause errors to the script. Essentially, they have no effect on the script.

Advanced Controls radio button legacy Mathcad 15 Radio Button Recalculate method script editor in Mathcad Prime

In the above screenshot, you can see the Recalculate method that was part of the original script in legacy Mathcad. It does not work, but it also does not cause errors. Although not mandatory, it is a good idea to delete this part, to keep the code clean and to avoid confusion.

In some cases, you may need to modify your script further, to fit your specific workflow.

Converting VBScript to JScript or Python

Another important note is that when converting scripts written in VBScript, it might be a good idea to go one extra step forward and convert them to JScript. The reason for this is that Microsoft corporation has announced that VBScript will be deprecated in the future.

In Mathcad Prime 11.0.0.0, Python will be introduced as a scripting environment for advanced controls. You might consider converting to Python as another alternative.

Converting VBScript to JScript or Python can be challenging due to differences in syntax, data types, built-in functions, and more. You will typically need to manually rewrite the script, taking these differences into account. The simplest and most efficient way is to recreate the VBScript logic and then implement it using JScript or Python syntax. You can use online conversion tools or generative AI, but always check the script to ensure it works as expected.

Syntax Changes

In legacy versions of Mathcad, JScript events used the following syntax:

function MyEventSrc::Event1()

In PTC Mathcad Prime, the double colon (::) is replaced with an underscore (_). Here is the updated syntax:

function MyEventSrc_Event1()

When converting advanced controls from legacy Mathcad to Mathcad prime, the double colon (::) is not converted to underscore (_), but the script reads it as underscore and works as expected. In this case as well, consider manually changing to the contemporary syntax to avoid confusion and keeping consistency.

Using Advanced Controls with the Mathcad Prime API

 

The Mathcad Prime API is different than the legacy Mathcad API. Consequently, when you convert advanced controls that used the legacy Mathcad API, you must rewrite them so they will work with the current Mathcad Prime API.

Read the help chapter on Automation in Scriptable Controls and review the examples provided there to gain better understanding.

Summary and Conclusion

To convert your legacy advanced scriptable controls, start by using the Mathcad converter. After conversion, check the conversion log for any necessary adjustments. Use the Mathcad Prime Help Center and the Migration Guide to learn about active, modified, and inactive properties and methods. Some workflows will need no change, others will require syntax modifications, and there will be some workflows that would require more adjustments. If you have controls programmed with VBScript, consider converting them to JScript (or Python, starting with Mathcad Prime 11.0.0.0) to ensure future compatibility.


Advanced Controls Crash Course

Learn more about use cases for all of the Advanced Controls by attending our free, on-demand training event: the Advanced Controls Crash Course!

Tags:

Converting Your Legacy Advanced Controls Scripts to Mathcad Prime
Read this blog post on how to convert the scripted controls from your legacy PTC Mathcad worksheets (like Mathcad 15) to PTC Mathcad Prime.