Example 9: JavaScript
This example runs through a series of APIs that exercise typical end user functions. It shows how you can make custom API calls, such as setting titles, getting input and output values, and changing values and units.
2. Run javascript example.js using Command Prompt. A Windows Script Host notification window opens. Click OK to dismiss this window.
3. PTC Mathcad Prime opens. A Windows Script Host notification window opens to inform you that PTC Mathcad Prime started successfully:
Click OK to dismiss this window.
4. The API opens a test worksheet. A Windows Script Host notification window opens showing the number of input regions in the worksheet, and the alias for the first input.
5. In the worksheet, note the two input regions that define the input1 and matrixInput1 variables:
Click OK to dismiss this window.
6. A Windows Script Host notification window opens informing you the API uses the SetRealValue method to change Input1 from 45 kg to 12.2341 km. Click OK to dismiss this window.
7. The value of Input1 changes to 12.2341 km. A Windows Script Host notification window opens showing the number of output regions in the worksheet, and the alias for the first output:
Click OK to dismiss this window.
8. A Windows Script Host notification window opens informing you the API uses the GetRealValue method to read the new value of Output1. Click OK to dismiss this window.
9. A Windows Script Host notification window opens informing you:
◦ PTC Mathcad Prime will close if all open worksheets are saved, and if there are no other COM clients.
◦ PTC Mathcad Prime remains open if you do not save any modified worksheet.
Click OK to dismiss this window.
10. A prompt appears asking you to confirm you want to save the changes you made to the test worksheet.
11. Click Don’t Save to close the worksheet and close PTC Mathcad Prime.