Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline gregi  
#1 Posted : 22 March 2017 17:51:14(UTC)
gregi

Rank: Newbie

Groups: Registered
Joined: 20/02/2017(UTC)
Posts: 5
Poland

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 Good

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline csb531  
#2 Posted : 22 March 2017 18:33:09(UTC)
csb531


Rank: Member

Groups: Registered
Joined: 10/10/2012(UTC)
Posts: 24
Netherlands

Hello Gregi,

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

Regards, csb
Offline uni  
#3 Posted : 22 March 2017 19:04:37(UTC)
uni


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 10/11/2010(UTC)
Posts: 1,494
Man
Russian Federation

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 ) );


2017-03-22 21-00-51 SMath Studio - [List1.sm ].png
Russia ☭ forever
Viacheslav N. Mezentsev
thanks 1 user thanked uni for this useful post.
on 22/03/2017(UTC)
Offline gregi  
#4 Posted : 22 March 2017 20:31:07(UTC)
gregi

Rank: Newbie

Groups: Registered
Joined: 20/02/2017(UTC)
Posts: 5
Poland

Was thanked: 1 time(s) in 1 post(s)
Thank you uni! Your solution is exactly what I needed Good
Users browsing this topic
Guest
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.