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 wb.c  
#1 Posted : 06 July 2023 19:38:05(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 135
United States

Was thanked: 22 time(s) in 19 post(s)
This is probably not possible given what I have already read on other related posts, but I just want to see if anyone has any ideas.

When we define a variable, we have the choice to change the unit we display with that defined variable. We usually need to do this if the desired unit is something different than what is the default unit.
We can use var2str(1) to convert that value and unit to a string, so long as the unit is the default, the string will match the original input.
If the unit is not a default unit, then the string will show whatever value was originally defined, converted into the default unit.
The only thing that seems possible at this time is t manually cancel out the units before converting to a string in order to keep the original value, but the unit text is now lost.
other functions like UnitsOf(1) also only display the default unit.

2023-07-06 12_18_55-SMath Solver 1.0.8348 - [Worksheet8_].png

Is there a way to convert the defined variable into a string while keeping the original unit shown?
Something like this:
2023-07-06 12_27_53-SMath Solver 1.0.8348 - [Worksheet8_].png

If this is not possible, maybe it could be possible to detect the defined unit, something like this:
2023-07-06 12_32_15-SMath Solver 1.0.8348 - [Worksheet8_].png

It seems like any unit other than the default is just a conversion factor changing the display. It doesn't change the actual value of the variable as far as the calculations are concerned. So I understand that in the "background" the unit is still the default, and only my selection of "in" has modified the original value to convert it and show it in inches. Maybe a function could be made to show the displayed units of a variable? This way the distinction between defined units, and displayed units is made.
Something like this:
2023-07-06 12_37_02-SMath Solver 1.0.8348 - [Worksheet8_].png

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

Offline wb.c  
#2 Posted : 06 July 2023 20:20:38(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 135
United States

Was thanked: 22 time(s) in 19 post(s)
To add to this, if we define a variable, along with a unit (not a default unit).

2023-07-06 13_16_10-SMath Solver 1.0.8348 - [test.sm].png

Then we open the .sm file in note pad and look at code, we see that the "unit" operant of "in" is defined.
2023-07-06 13_16_28-test.sm - Notepad.png

So why can't we get that bit of information for use in other operations?
Offline Razonar  
#3 Posted : 06 July 2023 20:54:13(UTC)
Razonar


Rank: Advanced Member

Groups: Registered
Joined: 28/08/2014(UTC)
Posts: 1,371
Uruguay

Was thanked: 834 time(s) in 528 post(s)
Originally Posted by: wb.c Go to Quoted Post
... Is there a way to convert the defined variable into a string while keeping the original unit shown?


Hi. Artificial, but it's a way. A Hold() function obviously is better:

Clipboard1.png

mcad_hold.sm (5kb) downloaded 6 time(s).

Best regards.
Alvaro.
Offline wb.c  
#4 Posted : 06 July 2023 21:58:49(UTC)
wb.c


Rank: Advanced Member

Groups: Registered
Joined: 02/04/2018(UTC)
Posts: 135
United States

Was thanked: 22 time(s) in 19 post(s)
Hi Alvaro,

Thanks for this initial try.
I would like to avoid using the mathcad plugin. Not a huge fan of how the variable is defined, and in the end, if this is the only way, maybe just mathcad is a better solution...
Realistically, this probably requires an additional special function, that allows you to recall the "displayed" units.
As I have shown, code contains the display units as an operant, so this should be able to be recalled in some way.

I know a lot of people would just want to see a way of showing the initial substitution, but this request has been put forth for over a decade now with no result, so it must be hard, or the dev team is not financially motivated for this.
Personally, I think that this type of feature would really make Smath a better engineering calculation tool.
So, if this can't be done, then at least this simple request to recall the displayed unit can be done, and then with what you have already done, we can make a function that does this substitution for us.
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.