LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to determine if digital control has custom format string

Solved!
Go to solution

I want to be able to find all numeric controls that are using a non-default format string. Right now I have a VI Analyzer test that looks at all numerics, gets their format string and compares it to some defaults that I have hand coded. Integers are all %.0f and everything else is %#_g. I'm not a huge fan of this since it can be fragile. NI might add new representations (since I've started LabVIEW we'd added 64-bit integers and fixed-point) or maybe even change the default format.

 

Ideally there would be a "Custom Format String?" property, but I don't see that as an option.

 

Or, a way to see what the default format string is for a specific numeric and compare that to the actual format string. 

 

I actually have a VI the scripts a new VI, adds a new numeric control for each possible representation (using vi.lib\numeric\LVNumericRepresentation.ctl) and gets the format string. This way I always get the current default format string and all the representations (assuming NI keeps that typedef up-to-date). But I'm hesitant to integrate that into the VI Analyzer test. It just seems too kludgey, but maybe that's the current best option. 

 

Is there an easier way that I'm missing?

 

0 Kudos
Message 1 of 9
(1,176 Views)

I can't find any other way to do it.

0 Kudos
Message 2 of 9
(1,122 Views)

Another thought maybe: Aren’t you overthinking this a bit to much? Trying to mark VIs that have a control with very esoteric formatting is not a bad idea in itself but do you really care if a control is formatted %.3f or %.4f?

 

If it is a subVI, that formatting is never really used at all since the frontpanel is never opened and therefore the control never even rendered. For visible front panels the formatting is a function of the controls specific meaning and more often than not anyhow non-default.

Rolf Kalbermatter
My Blog
Message 3 of 9
(1,090 Views)
Solution
Accepted by topic author Lavezza

Hi Lavezza,

 

When you create a control on the front panel, either manually from the Controls palette or by scripting with e.g. VI method "Create from Data Type", it will simply make a copy from a template in your LabVIEW installation. For example, if you script the creation of a numeric control while your default style is "Silver", it will copy "<LabVIEW 20xx>\vi.lib\silver_ctls\Numeric\Numeric Control NI_Silver.ctl". If you modify the "Format String" property of this template, it will use the new format the next time you create a numeric control. So even your current script that creates a control on-the-fly could not work if some of the control templates where previously changed (for whatever reason).

 

What you can do is switching between all representations until one is incompatible with the current format, which forces LabVIEW to reset it to the default value for this representation:

raphschru_0-1703688021503.png

 

Fixed-Points are particular because the default format can be the integer format or the fractional format depending whether it represents an integer (Integer Word Length >= Word Length) or not. And sometimes even when your fixed-point is an integer, if your control was previously configured as e.g. a Double, LabVIEW can still accept the fractional format as a valid format for your fixed-point.

 

So my best attempt here is to try an integer representation first, then switching to fixed-point. If the bit representation is not comptatible with an integer, it will switch to the fractional format instead:

raphschru_1-1703688339211.png

 

Regards,

Raphaël.

Message 4 of 9
(1,071 Views)

Since you are talking about VI analyzer, I recommend to continue this discusssion in a better place.

0 Kudos
Message 5 of 9
(1,062 Views)

Perhaps this would be useful.

"If you weren't supposed to push it, it wouldn't be a button."
Message 6 of 9
(1,060 Views)

I started out with a test to find numerics formatted as relative or absolute time since those are easier to mess up. We had some indicators formatted as %<%H:%M>t when we really wanted %<%M:%S>t

 

Finding all controls with any non-default formatting is probably less useful but I thought I'd throw it together anyway. Probably time to let it go and get out of the rabbit hole.

0 Kudos
Message 7 of 9
(1,042 Views)

Raphaël,

 

Thanks. More complicated than I imagined. 

0 Kudos
Message 8 of 9
(1,040 Views)

Try this version

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 9 of 9
(992 Views)