Hello!
I'm making a wrapper for CoolProp library (yes, I know that Ian promised to do it, but I'm afraid there's no activity there, and I thought like helping them).
My plugin implements numeric evaluation (
IPluginMathNumericEvaluation).
Everything seem OK when I simply return unitless numbers.
But when I try to assign units to the result (it is a physical properties library), it becomes complicated.
I use
SMath.Manager.UnitsManager.GetCurrentUnitName() to get current built-in units names; I use
SMath.Manager.Converter.ToTerms() and
SMath.Math.Symbolic.Converter.ToMItem() to make proper
MItem to assign to resulting
TNumber's
obj.Units. But it seems I do it wrong.
When the unit current name (e.g. 'K, 'm, 'J) is one-letter, it works OK. The returning result may be displayed by user using different units (say, 'F, 'in, 'kJ).
But if the unit current name is multiletter (say, 'mol, or ('J in Russian locale) 'Дж), the result is displayed correctly, but cannot be normally converted to different units; SMath handles the plugin-assigned unit as a "blob" and makes funny transformations to show "'mol/'{m^3}" as "'kmol/{m^3}".
This is the first problem.
The second is when I make functions that return strings. There seem to be no "string" type in SMath. Instead, strings are a kind of
TDouble with
isText set to
true. I make string results as
new SMath.Math.Numeric.TDouble("\"" + String + "\"" );This produces a number with
isText properly set to
true.
But when such a function is used inside other that requests textual arguments, an error is emitted that says "Here must be a string!".
What is wrong with the code?
I attach the plugin source code here. The test file debug.sm is in the solution's root directory. The solution is made with VS 2013 Community. After building the debug version, it tries to copy plugin and CoolProp DLLs to SMath's user plugins directory. It should already exist (%appdata%\SMath\extensions\plugins\ca92ef03-c7da-4888-98ad-528482733e2f\1.0.0.0\). I haven't yet considered how the plugin should install and register itself; this is a work to do...
Thank you very much for attention, and even more for help!