Editor’s Note: This blog is based on a PTC Mathcad Prime 10 worksheet. Download the accompanying List Box worksheet here. If you do not have a Mathcad Prime 10 worksheet viewer, download our free 30-day trial here.
In engineering and scientific calculations, providing users with an intuitive and interactive way to select input parameters is crucial for enhancing productivity and accuracy. PTC Mathcad Prime 10 offers a list box along with other advanced control feature to facilitate this. However, many users may not be fully aware of how to effectively implement and utilize list boxes to dynamically update calculations and enhance the user experience in their worksheets. This blog aims to address this gap by detailing the creation, configuration, and application of list boxes in Mathcad Prime, demonstrating their benefits in practical scenarios, and providing step-by-step guidance to leverage this tool for more efficient and error-free data input.
The list box in Mathcad Prime is used to:
To create a list box in Mathcad Prime 10:
The default script for a list box in Mathcad Prime defines several key components and events that manage the list box's behavior. Here is a detailed explanation of the script, including the major events:
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.
The default script sets up a list box with three items and initializes the first item as selected. It includes placeholders for additional initialization, execution, stopping, selection change, and double-click events, allowing users to customize the behavior of the list box according to their needs.
By adding appropriate code to these placeholders, users can make the list box interact dynamically with other parts of the Mathcad Prime worksheet, responding to user selections and triggering calculations or updates as required.
In the petroleum industry, selecting the appropriate crude oil type and understanding its by-products is crucial for efficient refining operations. This process involves multiple steps, from choosing the crude oil type to calculating the necessary pipe diameter for transporting these by-products. Using Mathcad Prime, we can create an interactive and dynamic worksheet to streamline this process. This blog post will guide you through a comprehensive use case that demonstrates how to utilize list boxes in Mathcad Prime for these calculations. You may also watch the embedded video about this same worksheet to follow along.
The first step involves selecting a crude oil type from a list of ten options. This list box allows users to choose the specific type of crude oil they are working with. Upon selection, the main by-products associated with the chosen crude oil type will be populated in a second list box. The output is set to get the standing of the oil in the list (the index number to which selected oil is listed) along with the name of the oil.
The left side of this control is hidden in the worksheet , and this can be done by going to Input / Output > Controls > Hide Left Side.
Features utilized to construct this list box:
Methods | Formatting properties | State Properties |
---|---|---|
AddString | RightAlignedText | CurSel |
GetText | ||
ResetContent |
In the second list box, users can select a by-product. The output will dynamically update to display based on selection of list box 1.
The output consists of 1 x 3 Matrix which is as follows:
Features utilized to construct this list box:
Methods | Formatting properties | State Properties |
---|---|---|
AddString | RightAlignedText | CurSel |
GetText | Count | |
ResetContent |
Users can then select the flow rate and velocity based on the chosen by-product. These selections are crucial for determining the appropriate pipe diameter and are dynamically updated based on selection.
Features utilized to construct these list boxes:
Methods | State Properties |
---|---|
AddString | CurSel |
GetText | |
ResetContent |
Users can add a new volume to the list box by entering a value in a text box and appending a space to confirm the addition. The list of tank volumes is then updated accordingly. This will also check if the number entered is already in the list and then will not add the repeated number.
You now have the option to choose from the pre-defined list box and an added customised tank volume. Here are the features used for the Step 4 List Boxes:
Methods | Formatting properties | State Properties |
---|---|---|
AddString | RightAlignedText | CurSel |
DeleteString | ||
FindString | ||
FindStringExact | ||
GetText | ||
ResetContent |
With the help of flow rate and velocity, you can now calculate the diameter for the selected byproduct.
Using list boxes in Mathcad Prime offers several distinct benefits over other advanced controls. Here are ten key advantages:
List boxes provide a straightforward and user-friendly way for users to select from a predefined set of options. This simplicity makes them easy to understand and operate, even for users with limited technical expertise.
By restricting input to a set of predefined options, list boxes significantly reduce the risk of user input errors compared to text fields or other free-form input methods.
List boxes can be dynamically updated based on user selections. For example, selecting a crude oil type can automatically populate the by-products list box, ensuring relevant and context-specific options are always available.
List boxes support event handling for selection changes, double-clicks, and other interactions. This allows for real-time updates and calculations, enhancing the interactivity and responsiveness of the worksheet.
List boxes allow users to quickly select from multiple options without typing, saving time and improving efficiency, especially when dealing with extensive lists of items.
Items in a list box are clearly displayed, making it easy for users to see all available choices at a glance. This is particularly beneficial for presenting categorized or hierarchical data.
Selections in list boxes can be directly linked to variables used in calculations. This seamless integration simplifies the process of using user inputs in computational formulas, ensuring that calculations are always based on the latest selections.
Changes in list box selections can trigger automatic updates in related calculations and outputs, ensuring that the worksheet always reflects the current state of user inputs without requiring manual updates.
List boxes can be easily customized to include any number of options, tailored to the specific needs of the worksheet. This flexibility allows for precise control over the data input process.
When used in conjunction with multiple list boxes, hierarchical selection can be implemented (e.g., choosing a crude oil type, then its by-products leading to selection of flow rate and velocity), making complex data structures manageable and easy to navigate.
By integrating these list boxes and calculations into a Mathcad Prime worksheet, users can interactively select crude oil types, by-products, flow rates, velocities, and tank volumes. This approach ensures accurate and efficient calculations for pipe diameter, area, Reynolds number, and time required for filling tanks. The use of Mathcad Prime’s list boxes not only enhances user experience but also streamlines complex engineering calculations in the petroleum industry.
List boxes in Mathcad Prime offer an ideal balance of simplicity, interactivity, and efficiency, making them a powerful tool for managing user inputs in engineering calculations. Their ability to dynamically update, minimize errors, and integrate seamlessly with worksheet variables makes them superior to other advanced controls for many practical applications.
If you’re interested in learning more about the Advanced Control List Box Class, List Box Events, List Box Format Properties, List Box Methods and List Box State Properties 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!