API - Entry.Create() with unit

API - Entry.Create() with unit - Messages

#1 Posted: 3/22/2017 11:51:14 AM
gregi

gregi

1 likes in 5 posts.

Group: 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 Posted: 3/22/2017 12:33:09 PM
csb531

csb531

0 likes in 24 posts.

Group: 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 Posted: 3/22/2017 1:04:37 PM
Вячеслав Мезенцев

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

1402 likes in 1708 posts.

Group: 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 users liked this post
gregi 3/22/2017 2:30:00 PM
#4 Posted: 3/22/2017 2:31:07 PM
gregi

gregi

1 likes in 5 posts.

Group: User

Thank you uni! Your solution is exactly what I needed
  • New Posts New Posts
  • No New Posts No New Posts