cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Getting output type before using OutputGetStringValue, OutputGetRealValue

Cody_Godines
7-Bedrock

Getting output type before using OutputGetStringValue, OutputGetRealValue

Hi, I am using the API, and have a working code.  However, for generality, when getting output results I cannot tell what type is it.  For example, if I use 

 

....

 

Outputs = WS.Outputs

For i = 0 To WS.Outputs.Count - 2
var = Outputs.GetAliasByIndex(i)


varval = WS.OutputGetRealValue(var)
varvalstr = WS.OutputGetRealValue(var).RealResult.ToString
varunitstr = varval.Units

imsg = imsg + "Index=" + Str(i) + " , Name= " + var.ToString + " , Value= " + varvalstr + " , Units= " + varunitstr + vbCrLf
Next

 

...

 

How can I tell before calling OutputGetRealValue that my output is a real number not a string or matrix?  

 

Cody

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

The good news

There are four equals signs in mathcad.  The assignment equals which is acolon and an equals sign, the comparison equals which is a bold equals sign, the global equals sign that is three horizontal short lines, and the one that concerns us the display equals sign that is an equals sign.  to get a matrix as an output value use the equals sign to display the matrix, select all of this equation and then use menu Input/Output | Integration | Assign Outputs

Capture2.JPG

The bad news

The API does not work for matrices that contain any element is a string, nested matrix, or complex variable.  The API assumes all matrices have real numbers only hence no methods to check this assumption.

 

Cheers

Terry

View solution in original post

4 REPLIES 4

Hi,

Examine the following code snippet located in attached text file.:

How to tell if value is a string, scalar, or matrix.

Cheers

Terry

Hi terryhendicott,

 

I was able to follow your snippet, modify, and it worked for the real and string. Thank you for taking the time to answer me.  I appologize i did not know it was answered until this week.

 

The part of the matrix, I was left with this,

 


hereResult = WS.OutputGetMatrixValueAs(WS.Outputs.GetAliasByIndex(a), "")
rowCount = hereResult.MatrixResult.Rows
colCount = hereResult.MatrixResult.Columns
Dim Start As String
Start = "L7"
For inrow = 0 To rowCount - 1
For incol = 0 To colCount - 1
Dim b As Integer
b = hereResult.MatrixResult.GetMatrixElement(inrow, incol, dblhere)
Debug.Print(b)
'Worksheets(WorksheetName).Range("L7:L7").Offset(inrow, incol).Value = dblhere
Next incol
Next inrow

 

---

I am trying to test it but cannot seem to set a matrix as an output variable in mathcad prime 9.  I've tried tables and matrices.  Also, how do i know the matrix item will be a double value?

 

Much appreciated!

Hi,

The good news

There are four equals signs in mathcad.  The assignment equals which is acolon and an equals sign, the comparison equals which is a bold equals sign, the global equals sign that is three horizontal short lines, and the one that concerns us the display equals sign that is an equals sign.  to get a matrix as an output value use the equals sign to display the matrix, select all of this equation and then use menu Input/Output | Integration | Assign Outputs

Capture2.JPG

The bad news

The API does not work for matrices that contain any element is a string, nested matrix, or complex variable.  The API assumes all matrices have real numbers only hence no methods to check this assumption.

 

Cheers

Terry

Hi @CG_9625485,

 

I wanted to follow up with you on your post to see if your question has been answered. 
If so, please mark the appropriate reply as the Accepted Solution. 
Of course, if you have more to share on your issue, please let the Community know so that we can continue to help you. 

 

Thanks,
Anurag

Top Tags