Skip to main content
1-Visitor
July 27, 2016
Solved

Trying to populate string data array using API

  • July 27, 2016
  • 3 replies
  • 8937 views

I want to pass a table of data into Mathcad.

Each row of data is like fluid_description (string), fluid_density (real value with units), fluid_viscosity (real value with units)

I have succeeded in sending a matrix of numerical values with and without units, and also individual string values.  But can't seem to find how to send a matrix of strings.

Also worth mentioning that whilst for now I'm using the API, in future it would be intended to migrate this to Mathcad gateway.

Any advice welcome.

Best answer by StuartBruff

Mathcad Prime (3.1) or Mathcad 15?

Can you write the data to a text file (or Excel) and then use Mathcad's file I/O functions to get the data?

Stuart

3 replies

1-Visitor
July 27, 2016

I don't have an answer for you, but as a workaround, could you just populate separate arrays and then combine them in Mathcad?

acarter-21-VisitorAuthor
1-Visitor
July 27, 2016

Whilst researching this problem, I also found Mathcad Tables, which are pretty cool and present the data nicely. 

But again, I don't see any API method for setting Table rows.  However I was able to insert a matrix into a table, which kind of works ... except still no possibility that I can find to create an array of strings.

        [DispId(18)]

        int SetMatrixValue(string aliasArg, IMathcadPrimeMatrix valueArg, string unitsArg);

        [DispId(11)]

        int SetRealValue(string aliasArg, double valueArg, string unitsArg);

        [DispId(36)]

        int SetSExprValue(string aliasArg, string sexpressionArg);

        [DispId(33)]

        int SetStringValue(string aliasArg, string valueArg);

The value parameter for SetMatrixValue is data type IMathcadPrimeMatrix, which has only one value setter method, and this demands value as double:

        [DispId(3)]

        int SetMatrixElement(int rowIndexArg, int columnIndexArg, double valueArg);

Thanks for the suggestion, I am at this stage convinced there is no way to do what I need, the workaround suggested will work if I abandon the string descriptions.

Of course I could send the string description as an integer array of ASCII codes, and convert it in Mathcad... but that's just crazy!

1-Visitor
July 27, 2016

I don't think many people have gotten much use from Prime's API, so I wouldn't expect much help on this site (though, feel free to post just in case).  I've only done a little playing with Prime's API to verify it can do what I need (simple import of a list of variables), but I've decided to stick with Mathcad 15 for now.  Additionally, my current computer only has Prime 1.0, so I can't even look much up.  Sounds like you've got a plan in mind - good luck!

23-Emerald V
July 27, 2016

Mathcad Prime (3.1) or Mathcad 15?

Can you write the data to a text file (or Excel) and then use Mathcad's file I/O functions to get the data?

Stuart

acarter-21-VisitorAuthor
1-Visitor
July 27, 2016

That's something I have not tried yet.  It sounds like it could work.

1-Visitor
September 6, 2016

Did you find a solution ao far and do you like to share it?

acarter-21-VisitorAuthor
1-Visitor
September 7, 2016

As far as API calls, I did not find any solution.  The suggestion from Stuart to use text file is good alternative.

19-Tanzanite
September 7, 2016

Why does modifying the XML of a region, as I suggested above, not work? You should be able to create any valid math region that way.