I have a question at the end of this message. Once my macros are thoroughly debugged, I will upload them.
I've created a set of macros that allow for variables to be "type checked". So basically you set your variables this way:
And then you do calculations like this: (full expressions with functions are supported!!)
My macro will perform type conversions if possible, and throw errors otherwise. So it can convert integers to reals, for example, within any expression.
It does other things too, because it stores more than just a "type" value within each variable. Each variable is actually treated as a JSON container which looks like this:
{"TimeModified":"1735446818","Type":"Real","Value":"5.71828"}
You can see three of the four things it stored for each variable in that example.
There is also a type conversion macro that looks like this:
Currently there are five data types supported: Boolean, String, Whole, Integer and Real. But it would not be hard to add more. Many of my variables are integer values from 0 to 100, so I'm planning to create a data type called Percent. I might also add Complex, just for the fun of it.
Any feedback before I release it would be appreciated, including "why are you doing this?" As always, my reasons for writing macros are:
- 25% for fun
- 25% for education
- 25% for my own personal needs
- 25% to help others
One question that I have, which I would like help with, is what is the best way to determine if a KM variable contains a valid numeric value (maybe regex? valid numeric values would include 1, 3.1415926, -4, 0x100, $5A, 8#007, etc.) I found a way, but it seems clumsy. Does anyone have a truly simple way to check for this?