Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
Does anybody know the correct code for reading out matrix content with JScript in MathCAD when loading it through the API?
This is the MathCAD simplified example in MathCAD Prime 11.
This is the code in the button:
Reading a matrix value like this works excellent when loading the Matrix as a normal input variable without API.
Other API functions works fine, like for instance Worksheet.Output.GetValue("EampleNumber").RealResult
Hi,
Try matrixFirstValue = matrix(0, 0)
Cheers
Terry
Hi,
Thank you for your proposal.
Unfortunately I get another error message: "Object doesn't support this property or method".
I tried both comma and dot as separator just to make sure.
I'm not sure that your variable matrix is a proper JScript array. I think it might be a different kind of object.
Try result = matrix.GetMatrixElement(0, 0, mydata); (result and mydata are arbitrary names)
Stuart
(Any chance you could post the worksheet with your example, please? I've probably made a typo as I can't get the number of rows or columns, let alone a matrix value)
Hi Stuart,
Thank you for looking into this. I have made an example worksheet, please see the attached MathCAD Prime 11 file.
In the worksheet there are two examples, one with standard input and one with API input.
With standard input it works fine but not when going through API, so there is something I don't get right with the syntax when working through API.
The code in the buttons are attached in case of problems with opening the mathCAD sheet. A screenshot of the sheet is shown below.
André
I'm sorry, André, but I can't see why your JScript code doesn't work. I tried changing your code to make it more resemble the example C# output code example, but that didn't change anything (as I hoped it wouldn't!).
I've tried converting it to Python, but I couldn't find an example of how to access a worksheet's In and Out variables. I'm not sure that Python scripting supports the Mathcad API, as the "Automation in Advanced Controls" Prime 11 Help states "Advanced controls that are scripted in VBScript or JScript can be used with the PTC Mathcad Prime API."; no mention of Python, which might be an omission or might be true.
The same for VBScript. Searching the forum reveals that I used to know something about VBScript back in the Good Old Days of Mathcad 11 (including the fact that "Worksheet" can be used for the active worksheet without any prior setup). However, my memory has long since gone walkabout wrt VBScript. My attempt to access the In matrix resulted in an reporting that I was using the Mathcad 15 API. I couldn't find a Prime VBScript example that accesses the In and Out variables; The VB API examples are sufficiently different to prove of little value to me.
Perhaps a control API scripting guru could help?
@DJNewman. Dave. Does Python scripting support the Mathcad API? If so, are you aware of any examples of using to access In and Out variables (or getting at the Active Worksheet)?
Stuart
I had no success, too - but I am all but a scripting expert.
Others seem to have already failed with API, JScript, and matrices as well.
How could I get a value from a matrix with js?
And yes, when it comes to documentation, there is still a lot of room for improvement (a huge amount of room) in this area.
@StuartBruff wrote:
@DJNewman. Dave. Does Python scripting support the Mathcad API? If so, are you aware of any examples of using to access In and Out variables (or getting at the Active Worksheet)?
I believe that Python-scripted Advanced Controls support the Mathcad API, but the only example I've seen of it was an internal one that wouldn't work when I was using their worksheet on my machine. 😞
Thanks, Dave.
Is there anybody on the development team you could ask about working with the Python scripting language and the Mathcad Prime API?
Thanks,
Stuart