07-10-2021 04:43 AM - edited 07-10-2021 04:50 AM
I would like to change the digit of precision for controls and indicatros in running my code.
A cluster contained several numeric controls.
In simple idea, all references can be collected then one for-loop is enough for this in real time.
As you can see precision.vi, why there is a buffer allocation in build array? or how to handle the compatible reference type?
In more trial, I can find the alternative way but I am not sure if this is the best way for my purpose.
labmaster.
Solved! Go to Solution.
07-10-2021 08:48 AM - edited 07-10-2021 08:49 AM
What is the question? ("your alternative way" does not really do anything better, except there is more code but you eliminate the coercion dots. These are NOT buffer allocation dots!)
You get the red coercion dots because some references are strict and others are not. That is not a performance issue and you can ignore that.
Do you have performance problems? Make sure that the FOR loop only executes whenever the precision changes, which is probably rare. What do you mean by "real time"?
07-10-2021 09:23 AM
Personally, I would even eliminate that extra FOR loop as follows. Less clutter. 😄
(Make sure to wire the error out to avoid automatic error popups, e.g. if your cluster also contains incompatible elements, such as a boolean)
07-11-2021 10:39 AM
@altenbach wrote:
Personally, I would even eliminate that extra FOR loop as follows. Less clutter. 😄
(Make sure to wire the error out to avoid automatic error popups, e.g. if your cluster also contains incompatible elements, such as a boolean)
Personally, I'd pretty much always follow @altenbach's advice.
07-11-2021 07:35 PM - edited 07-11-2021 07:36 PM
>there is more code but you eliminate the coercion dots. These are NOT buffer allocation dots!
Thank you for the response.
Can you explain why the coercion dot does not allocate a buffer?
Is it a special exception for the data type of reference?
Where can I find the related statement?
labmaster.
07-12-2021 05:34 AM
@labmaster wrote:
>there is more code but you eliminate the coercion dots. These are NOT buffer allocation dots!
Thank you for the response.
Can you explain why the coercion dot does not allocate a buffer?
Is it a special exception for the data type of reference?
Where can I find the related statement?
Coercion changes data from one type to another. That would often require a new memory buffer, as the data size and\or data layout can be different.
Type casting is just a way to tell the compiler (and programmer) the (expected) type of the object. A To More General is pretty much a no-op during run time. A To More Specific has error checking, but doesn't effect the object. The input object either is the new type or it isn't. There simply isn't much to do at compile time. The object doesn't change at all.