Skip to main content
12-Amethyst
July 9, 2024
Question

Getting output type before using OutputGetStringValue, OutputGetRealValue

  • July 9, 2024
  • 2 replies
  • 1758 views

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

 

2 replies

21-Topaz II
July 10, 2024

Hi,

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

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

Cheers

Terry

12-Amethyst
July 24, 2024

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!

21-Topaz II
July 24, 2024

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

Community Moderator
July 23, 2024

Hi @CG_01_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