SMath Studio Forum
»
SMath Studio
»
Questions
»
API - Entry.Create() with unit
Rank: Newbie
Groups: Registered
Joined: 20/02/2017(UTC) Posts: 5 Was thanked: 1 time(s) in 1 post(s)
|
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
|
|
|
|
Rank: Member Groups: Registered
Joined: 10/10/2012(UTC) Posts: 24
|
Hello Gregi,
Could you please post your smath-file or at least a screenshot, so i can understand your question better?
Regards, csb
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 10/11/2010(UTC) Posts: 1,494 Was thanked: 1274 time(s) in 745 post(s)
|
One possible way. Code: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 ) );
|
Russia ☭ forever Viacheslav N. Mezentsev |
1 user thanked uni for this useful post.
|
|
|
Rank: Newbie
Groups: Registered
Joined: 20/02/2017(UTC) Posts: 5 Was thanked: 1 time(s) in 1 post(s)
|
Thank you uni! Your solution is exactly what I needed
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Questions
»
API - Entry.Create() with unit
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.