I would like to know if it is possible (and how to implement it) to have a custom data type for macro variables. Currently there are string, integer, double, boolean and field available and the one I am asking about is the double type.
Our 'regional' preference is a comma ',' as a decimal sign not a dot '.' so my numbers in fields on the screen are displayed as 31,01 instead of 31.01.
If I try to extract a field into a variable of double type I only get the first part of the number eg. 31 and the 01 is missing. The current workaround is using a string type, but I believe you can see that this is not a clean solution, especially if trying to do evaluations for less-than or greater etc.
Is there a way I could change the settings in a macro for double type to use a comma for decimal sign or should I implement a custom data type?
Any help is appreciated!
Pinned topic Custom types - double type decimal comma not a dot
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-02-07T16:35:42Z at 2013-02-07T16:35:42Z by SystemAdmin
tmparker 120000EHB3518 Posts
Re: Custom types - double type decimal comma not a dot2013-01-22T15:40:33ZThis is the accepted answer. This is the accepted answer.Hi,
In Java the numeric data types only recognize the dot as a decimal separator. You can use built in Java classes and method to output the value in locale specific formats so that you would see the comma as the separator. However, this does not change how the values are handled internally, they can only be processed using the dot as the separator. If you wanted to create your own custom data type I guess you could. You would then need to implement all of the operations you want to perform. My guess is that you would have to pass in all the values that have the comma separators as strings, then convert the comma to a dot, then convert to a Java numeric type, perform your operation and finally convert the result back to a string with your comma separator and return that value. If you were simply comparing two values you would just need to return a boolean back in that case.
Re: Custom types - double type decimal comma not a dot2013-01-23T13:20:46ZThis is the accepted answer. This is the accepted answer.
- tmparker 120000EHB3
It does sound like a lot of hassle and being somewhat Java inexperienced sure doesn't help. I might try doing something with custom data types but for now I will have to solve problems like these outside of HATS.
I will leave the question as unanswered for a few days if someone who perhaps had and solved this problem stumbles upon it.