LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to convert reference of control to strict?

Solved!
Go to solution

@mcduff wrote:

If you go down the route of going to a more specific class, then your "For loop" in one of the VIs that you uploaded would need a case structure in the loop in order to pick the correct class.

 

Someone wise on these forums says, "do more with less code." I suggest you follow that advice.

 

mcduff

 

 


Are you referring to my code or the OP's code? If you're referring to my code, there is a case structure there, it's just looking at an error flag. You could use multiple parallel ones of those or a nested stack of them.

 

Also, I did just try the format string of %.0f and it doesn't show decimal points in the Double case, it throws them away- you need a 2 in there if you want two decimal points to show up.

0 Kudos
Message 11 of 15
(680 Views)

@BertMcMahan wrote:


The OP's code. He/she also setting a default value in his code, in addition to limits. Using a generic reference will use a variant input for value able to accept anything. If his/hers default value is floating that he/she needs to make sure they are using the correct class so it does not get coerced incorrectly for the double reference. I believe the OP wants the tip strip not to have decimal points for all cases.

 

mcduff

 

PS I just looked at your code and it would also work for the OP. I would get rid of the conversion to strict and replace the format specifier to only have %.0f for any case.

0 Kudos
Message 12 of 15
(675 Views)

@mcduff wrote:

 

PS I just looked at your code and it would also work for the OP. I would get rid of the conversion to strict and replace the format specifier to only have %.0f for any case.


I tried that and it doesn't work. A format specifier of %.0f will remove the decimal places. OP wants the tip strip for Floats to have 2 decimal places. In other words, "Valid values are 0.00 to 9.00" for floating point controls, and "Valid values are 0 to 9" for decimal controls. To get 2 decimal places, you must use a different format string of %.2f. There is no way for Format into String to know anything about the incoming format, so you MUST have some mechanism to change code based on the input's type. You therefore need either a case structure or a Type Specialization structure to have different code for different datatypes.

0 Kudos
Message 13 of 15
(667 Views)

Okay.

 

I thought the OP did not want decimal place for any tip strips. My bad.

 

mcduff

 

 

0 Kudos
Message 14 of 15
(660 Views)

@mcduff: Bert is correct saying that I want to have decimal place for floating point. 

Originally, I love to have the polymorphic vi works by itself. In this case, I think using one subvi with case structure is the only option.

0 Kudos
Message 15 of 15
(656 Views)