API - Entry.Create() with unit

API - Entry.Create() with unit - 消息

#1 已发布: 2017/3/22 11:51:14
gregi

gregi

1个赞,共5个帖子。

组: User

Hi,

I am beginning my yourney into SMath API. My current bigest problem is how to add a unit to custom function return value.
I am using IPluginLowLevelEvaluationFast interface and in my TryEvaluateExpression implementation I am returning some double value by: result = Entry.Create(TermsConverter.ToTerms(sampleDistance.ToString()));
It works ok, but the question is: how to add unit to result of TryEvaluateExpression, for example standard length measuer - meters ?
Can it be dony by Terms of result of function TermInfo?
Any help will be apreciated
#2 已发布: 2017/3/22 12:33:09
csb531

csb531

0个赞,共24个帖子。

组: User

Hello Gregi,

Could you please post your smath-file or at least a screenshot, so i can understand your question better?

Regards, csb
#3 已发布: 2017/3/22 13:04:37
Вячеслав Мезенцев

Вячеслав Мезенцев

1,558个赞,共1,868个帖子。

组: Moderator

One possible way.

var expr = new List<Term>();
var val = new Term( "10", TermType.Operand, 0 );
var unit = new Term( "'m", TermType.Operand, 0 );

expr.Add( val );
expr.Add( unit );
expr.Add( new Term( "*", TermType.Operator, 2 ) );

2017-03-22 21-00-51 SMath Studio - [List1.sm ].png
Russia ☭ forever, Viacheslav N. Mezentsev
1位用户喜欢此帖子
gregi 2017/3/22 14:30:00
#4 已发布: 2017/3/22 14:31:07
gregi

gregi

1个赞,共5个帖子。

组: User

Thank you uni! Your solution is exactly what I needed
  • 有新帖
  • 无新帖