Editor’s Note: This blog is based on a PTC Mathcad Prime 10 worksheet. Download the accompanying Button worksheet here. If you do not have a Mathcad Prime 10 worksheet viewer, download our free 30-day trial here.
The Button scriptable control in PTC Mathcad Prime 10 is a powerful tool for capturing user input through button selection and de-selection. While push buttons typically return a binary value of 1 or 0 (on or off), their behavior can be significantly enhanced through scripting, utilizing the Button class and other scripting language features. This blog explores the sophisticated capabilities of the Button control, its customization options, and the event-driven programming model that underpins its functionality.
To create a push button control in Mathcad Prime 10:
The default script for a Button control includes four key events: Start, Exec, Stop, and Click. Each of these events serves a specific purpose in the button’s lifecycle and interaction model:
The script can be written in either JScript or VBScript. However, please note that VBScript will be deprecated in a future Mathcad Prime release. Therefore, all the scripting in this worksheet has been implemented using JScript.
By default, push buttons provide basic functionality, but behavior can be extensively customized:
In this example, we have a Mathcad Prime 10 worksheet featuring three push buttons, each designed to perform a specific task. You can read along the explanations below, and/or watch the embedded video about this same worksheet to follow along. Note that since the video was produced, Button 1 has been edited to allow the user to input the location of the web content they would like to copy with a Text Box control, as opposed to the original functionality where the URL was hard-coded into the Button's Script Editor.
Clicking Open Word opens Microsoft Word and scrapes the contents of the URL put in the yellow Text Box.
Simplicity and Clarity: Automating repetitive tasks with push buttons saves time and effort, allowing users to focus on more critical aspects of their work.
Streamlined Workflow: Push buttons make Mathcad worksheets more interactive and user-friendly, improving the overall user experience.
Dynamic Interactivity: Automation reduces the risk of human error, ensuring that tasks are performed accurately and consistently.
Customization: Push buttons facilitate seamless integration with external applications (Microsoft Word in this case), extending the functionality of Mathcad worksheets.
Push buttons are powerful tools that enhance the interactivity, efficiency, and functionality of worksheets. By automating tasks such as web content copying, worksheet recalculation, and saving, push buttons enable users to streamline their workflow and improve productivity. The practical application of these push buttons in a Mathcad worksheet demonstrates their versatility and utility in real-world scenarios.
Incorporating push buttons into your Mathcad Prime 10 worksheets can transform the way you work, making complex tasks simpler and more efficient. Whether you are automating web content transfers, recalculating worksheets, or saving your progress, push buttons provide a powerful solution to enhance your productivity and accuracy.
If you’re interested in learning more about the Advanced Control Button Class, Button Format Properties, Button Events, and Example, then you may consult the Help documentation provided online and also inside the software.
Learn more about use cases for all of the Advanced Controls by attending our free, on-demand training event: the Advanced Controls Crash Course!