Post Reply 
Units Question
07-16-2019, 10:18 PM (This post was last modified: 07-16-2019 10:22 PM by Gene222.)
Post: #1
Units Question
Is there a way I can test to see if a variable has a unit attached to it?

I was using x:=UVAL(x); where I wanted to strip away the units. If x=5_m, then UVAL returns 5. If x=5 without any units attached, then UVAL returns an error message and it stops my program. I wanted to test x to see if it had units before using the UVAL command.
Find all posts by this user
Quote this message in a reply
07-17-2019, 12:24 AM
Post: #2
RE: Units Question
Syntax:
TYPE(object)

Returns the type of the object:
0: Real
1: Integer
2: String
3: Complex
4: Matrix
5: Error
6: List
8: Function
9: Unit
14.?: CAS object. the fractional part is the CAS type

should do it

-road
Find all posts by this user
Quote this message in a reply
07-17-2019, 01:14 AM
Post: #3
RE: Units Question
Thanks!
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)